On this page

Skip to content
Article Series:iPAS Exam Preparation Notes (1 / 2)

iPAS Exam Preparation Notes - Information Security Engineer

While preparing for the iPAS AI Application Planner (Entry Level) exam recently, I took some practice exams for the Information Security Engineer (Entry Level) from last year and found that I passed both subjects, so I decided to register for both. While using Gemini Gem to drill practice questions, I noticed that some terms and details are easily confused, so I decided to have the AI help me organize them into a set of notes, supplemented by my past engineering experience.

The following are just personal notes, and the content is not guaranteed to be entirely within the scope of the entry-level exam. I intentionally increased the difficulty in the Gemini Gem instruction settings, and the difficulty was raised in each round (20 questions per round, 5 rounds in total), so I suspect it covers more than the entry-level scope but does not cover the entire intermediate scope.

These notes are a collection of thoughts as they come, and I may add to them at any time while practicing. Additionally, there are many code snippets and command sections in the notes, which are included for easier understanding or for reference when needed, so I have collapsed them using details tags.

Basic Concepts

Fundamental Principles and Terminology of Information Security

CIA Triad (Core)

ConceptEnglishDescriptionControl Measures
ConfidentialityConfidentialityEnsure information is accessed only by authorized partiesEncryption, access control, data classification
IntegrityIntegrityEnsure information is not modified without authorizationHash verification, digital signatures, version control
AvailabilityAvailabilityEnsure authorized users can access information in a timely mannerBackup, disaster recovery, load balancing

Extended Security Attributes

ConceptEnglishDescriptionControl Measures
AuthenticityAuthenticityVerify the authenticity of the information sourceDigital signatures, PKI, multi-factor authentication
Non-repudiationNon-repudiationEnsure actions cannot be denied after the factDigital signatures, audit logs, timestamping services
AccountabilityAccountabilityEnsure actions can be traced to a specific individualIdentity authentication, access logs, separation of duties

AAA Framework (Authentication, Authorization, Accounting)

ElementEnglishDescriptionControl Measures
AuthenticationAuthenticationVerify user identity ("Who are you?")Account/password, MFA/FIDO2, biometrics
AuthorizationAuthorizationDetermine accessible resources ("What can you do?")RBAC, ABAC, OAuth 2.0
Accounting/AuditingAccountingRecord user actions for tracking ("What did you do?")Audit logs, SIEM, NetFlow

CIA vs AAA

  • CIA describes the security attributes that information should possess (protection goals); AAA describes the three stages of access control (implementation mechanisms). The two are complementary.

CIA and AAA Relationship Diagram

Diagram

Asset Value Assessment Criteria

Value TypeAssessment ElementQuantification MethodExample
Direct CostReconstruction, procurement costMonetary valueSoftware license fees, hardware equipment costs
Indirect CostOperational disruption, reputational lossRevenue loss estimationLoss per hour of system downtime
Legal CostRegulatory compliance, penalty riskPotential finesGDPR can fine up to 4% of annual turnover
Competitive ValueIntellectual property, trade secretsCompetitive advantage assessmentR&D results, customer lists

Defense in Depth

An architectural strategy of multi-layered security controls, providing protection even if a single layer is breached. The concept is similar to the layered defense of an ancient castle: if the wall is breached, there is a moat, and further in, there is an inner city and arrow towers. Each layer consumes the attacker's time and increases the risk of exposure.

LayerControl Measures
Governance LayerPolicy, Security Awareness Training
Physical SecurityAccess Control, CCTV
Network PerimeterFirewall / IPS (Intrusion Prevention System) / SDP (Software Defined Perimeter)
Internal NetworkZero Trust / NAC (Network Access Control)
Host SecurityEDR (Endpoint Detection and Response) / AppLocker (Application Whitelisting)
Application SecurityWAF (Web Application Firewall) / RASP (Runtime Application Self-Protection) / SSDLC (Secure Software Development Lifecycle)
Data SecurityEncryption / DLP (Data Loss Prevention)

Security Governance Document Hierarchy

LevelEnglishNatureExample
PolicyPolicyExplains "what to do" and "why," without specifying technical details. Approved by top management, mandatory, violation constitutes non-compliance."All data transmission must be encrypted"
StandardStandardExplains the "minimum technical threshold to meet policy requirements," mandatory. Specifies specific versions, algorithms, or settings, violation constitutes non-compliance."Use TLS 1.2 or higher"
ProcedureProcedureExplains "how to execute," lists sequences of repeatable operations. Mandatory, personnel must follow steps, deviation requires formal approval."Account Application SOP"
GuidelineGuidelineProvides recommended practices, non-mandatory. Personnel can judge whether to adopt based on context, deviation does not constitute non-compliance."Recommended password length of 12 characters or more"

Governance Document Hierarchy Diagram

Diagram

Information Ethics: PAPA Theory

Proposed by scholar Richard Mason in 1986, defining four ethical issues in the information age.

AbbreviationIssueCore Question
P (Privacy)PrivacyIndividuals have the right to decide whether to disclose their own information
A (Accuracy)AccuracyResponsibility for the authenticity and correctness of information
P (Property)Property/OwnershipOwnership of information intellectual property rights
A (Accessibility)AccessibilityUnder what conditions is one qualified to access information

Difference between Accessibility and Availability

Accessibility ≠ Availability: The former is "who is qualified to use it," the latter is "whether the system can be used."

Information Asset Classification Standards

LevelEnglishStandardTypical Example
PublicPublicDisclosure will not cause harmMarketing materials on the company website, announced financial reports
InternalInternalDisclosure will not cause major damage, but not actively leakedInternal company website operational procedure documents
ConfidentialConfidentialDisclosure may damage the enterpriseTrade secrets, unannounced product R&D plans
PrivatePrivateDisclosure may damage others' privacyEmployee ID numbers, customer credit card numbers, etc.

Information Asset Classification Judgment Process

Diagram

The "Will disclosure cause harm?" judgment on the flowchart assesses "whether leakage will cause concrete damage or compliance issues." The difference between "Public" and "Internal" is not the degree of harm, but "whether it is actively disclosed to the public": marketing materials are Public, while internal SOPs, even if leakage has little impact, are still Internal. In practice, whether something is classified as Public requires explicit approval from the asset owner; otherwise, it should default to Internal.

Government Data Classification

Taiwan's government classifies confidential data from high to low according to the "National Secret Protection Act": Absolute Secret → Top Secret → Secret. General official documents are distinguished as "Secret" or "General" according to the "Document Processing Manual." Similar to the enterprise four-level classification logic, the core difference is that government classification focuses on national security impact, while enterprise classification focuses on commercial damage.

After asset classification is determined, the next step is to clarify who is responsible for deciding the classification and who is responsible for implementing controls.

Asset Management Roles

RoleEnglishTypical HolderResponsibility
Asset OwnerAsset OwnerBusiness Unit ManagerDecides classification level, approves access authorization, bears final security responsibility
Asset CustodianAsset CustodianIT DepartmentImplements technical measures such as storage, backup, and access control according to owner instructions, has no authority to adjust levels independently

Key Points for Asset Classification Judgment

  • Level adjustments (including upgrades and downgrades) must be decided by the Asset Owner according to organizational policies and risk assessment procedures and cannot be changed arbitrarily; downgrades must be documented in writing for auditing.
  • Personally Identifiable Information (ID card, credit card number) → Private; Trade secrets → Confidential.

Difference from Information Security Roles

Similar to the direction of Asset Management Owner/Custodian, but the legal framework is different and cannot be directly equated:

  • Data Controller vs Asset Owner: The legal responsibility of the Controller is defined by GDPR/PII laws, and violations can be penalized by competent authorities; the responsibility of the Asset Owner comes from internal organizational policies.
  • Data Processor vs Asset Custodian: A Data Processing Agreement (DPA) must be signed in writing between the Processor and the Controller; the relationship between the Custodian and the Owner is an internal division of duties and does not require external contracts.

Regulations and Compliance

ISO/IEC 27001 and ISMS Basic Requirements

ISO/IEC 27000 Series Standards

StandardTopicCertifiable?Key Description
ISO/IEC 27000Overview of terms and definitions❌ Not certifiableDefines terms and concepts used throughout the 27000 series, serving as the foundational dictionary for reading other standards
ISO/IEC 27001Information Security Management System (ISMS) Requirements✅ Can apply for third-party certificationSpecifies the requirements that an organization must (SHALL) establish, implement, and maintain for an ISMS, and is the core of certification for the entire series
ISO/IEC 27002Information Security Control Measures Guidelines❌ Not certifiableProvides implementation suggestions (SHOULD) for control measures in Annex A of 27001, serving as an operational manual rather than a specification
ISO/IEC 27003ISMS Implementation Guidance❌ Not certifiableExplains how to implement 27001 clauses, providing implementation examples and recommended practices
ISO/IEC 27004Information Security Measurement and Evaluation❌ Not certifiableProvides design methods for measurement indicators, corresponding to 27001 Clause 9 (Performance Evaluation), assisting organizations in evaluating ISMS effectiveness
ISO/IEC 27005Information Security Risk Management❌ Not certifiableProvides guidance on the risk management process (Identification → Assessment → Treatment → Monitoring), providing a methodology for 27001 risk assessment
ISO/IEC 27006Requirements for Certification Bodies✅ (Applicable to certification bodies themselves)Specifies the conditions that third-party bodies performing ISMS audits and certifications must meet; not applicable to general organizations
ISO/IEC 27007ISMS Audit Guidance❌ Not certifiableProvides methodology for performing ISMS internal audits and third-party audits, supplementing ISO 19011 for information security audit scenarios
ISO/IEC 27017Cloud Service Security ControlsDepends on certification bodyAdditional control guidance for cloud providers and tenants, supplementing 27002 for cloud scenarios
ISO/IEC 27018Public Cloud PII ProtectionDepends on certification bodyGuidance for PII protection in cloud environments, consistent with the spirit of GDPR

ISO/IEC 27001 and SoA Key Points

  • 27001 Clauses 4–10 are mandatory (SHALL), and organizations must meet all of them to obtain certification.
  • Passing 27001 certification = ISMS management system complies with the specification; 27002 is a reference manual for "recommended practices" and is not certifiable itself.
  • The 93 control measures in Annex A do not require full implementation; organizations select applicable items based on risk assessment results and record the reasons for selection or exclusion for each control in the Statement of Applicability (SoA).
  • 27002 provides implementation suggestions (SHOULD) for each control measure; practices can differ from 27002, but must be explained in the SoA.
  • ISO only publishes standards and does not issue individual qualifications; Lead Auditor certificates are issued by personnel certification bodies (e.g., IRCA, PECB) in accordance with ISO/IEC 17024.

ISMS Core Elements

ElementEnglishDescriptionSpecific Requirements
ContextContextUnderstand organizational environment and stakeholder needsIdentify internal/external issues, regulatory requirements, stakeholder expectations
LeadershipLeadershipCommitment and participation of senior managementEstablish security policy, assign security responsibilities, provide resources
PlanningPlanningRisk assessment and goal settingPerform risk assessment, develop risk treatment plans, set measurable security goals
SupportSupportProvide necessary resources and capabilitiesManpower allocation, education and training, documented procedures, internal communication
OperationOperationImplement and run ISMSExecute risk treatment measures, control measure operation, supplier management
Performance EvaluationPerformance EvaluationMonitoring and measurementInternal audit, management review, performance indicator monitoring
ImprovementImprovementContinuous improvement mechanismHandling non-conformities, corrective actions, preventive actions

ISO 27001 Annex A Control Measure Categories

TopicEnglishNumber of ControlsScope
OrganizationalOrganizational37Security policy, roles and responsibilities, asset management, supplier relationships, incident management
PeoplePeople8Pre-employment screening, security awareness training, disciplinary procedures, termination procedures
PhysicalPhysical14Secure areas, equipment protection, cabling security, media disposal
TechnologicalTechnological34Access control, encryption, network security, secure development, vulnerability management
  • Total of 93 control measures (the 2013 version had 114; after the 2022 revision, 11 were added and others were merged and streamlined).
  • New controls include: Threat Intelligence, Cloud Service Security, Data Masking, Monitoring Activities, etc.

ISMS Effectiveness Indicators

Indicator TypeExample IndicatorTarget Value Reference
Preventive EffectSecurity awareness training completion rate, vulnerability patching timeTraining completion rate > 95%, high-risk vulnerability patching < 72 hours
Detection CapabilityMean Time to Detect (MTTD), false positive rateMTTD < 24 hours, false positive rate < 5%
Response EfficiencyMean Time to Respond (MTTR), incident resolution rateMTTR < 4 hours, resolution rate > 98%
Compliance DegreeAudit finding improvement rate, control measure effectivenessMajor findings 100% improved, control effectiveness > 90%

ISMS PDCA Cycle

ISO/IEC 27001 adopts the PDCA cycle to ensure continuous improvement of the ISMS:

StageEnglishCore Task
PlanPlanEstablish ISMS policy, goals, and risk assessment process, develop risk treatment plans
DoDoImplement and run ISMS policies, control measures, and procedures
CheckCheckEvaluate ISMS performance, perform internal audits and management reviews, report results to management
ActActTake corrective and preventive actions based on audit results to promote continuous ISMS improvement
Diagram

Audit Type (Three-Party) Comparison Table

TypeEnglishDescriptionTypical Example
First-party Audit1st PartyInternal audit, organization performs on itselfInternal security audit performed by the company itself
Second-party Audit2nd PartyAudit performed on external suppliers or partners; audit by competent authorities on subordinate agenciesFinancial Supervisory Commission audits banks under its jurisdiction; customers audit suppliers
Third-party Audit3rd PartyPerformed by independent verification/certification bodies, can issue certification certificatesISO 27001 certification audit

Judging Second-party vs Third-party Audits

  • Only third-party audits can issue external certification certificates (e.g., passing ISO 27001 certification).
  • Audits by competent authorities (e.g., Financial Supervisory Commission auditing banks) = Second-party, not third-party.
  • Common misconception: It feels like the competent authority is an "external independent third party," but in ISO definitions, external parties with a vested interest (regulatory agencies, customers) are all considered second-party.

Third-party Audit Certification Comparison Table

Certification / ReportNatureAudit ScopeFeatures
SOC 2 Type 1Third-party audit reportWhether system design at a specific point in time meets Trust Services Criteria (TSC)Point-in-time, only proves design is reasonable, does not verify actual operational effectiveness
SOC 2 Type 2Third-party audit reportWhether system operation over a period of time (usually 6–12 months) meets TSCPeriod-of-time, verifies control measures are continuously and effectively operating; more persuasive than Type 1
ISO 27001 CertificateThird-party certificationWhether ISMS management system meets ISO 27001 standardAnnual surveillance audit + recertification every three years; focuses on "management system" rather than technical control operational details
PCI DSS AoCAttestation of ComplianceWhether Payment Card Industry Data Security Standard (PCI DSS) requirements are met in the Cardholder Data Environment (CDE)Applicable to organizations handling credit card transactions, requirements vary greatly by level (Level 1 requires on-site audit by QSA)

SOC 2 Type 1 vs Type 2

  • Type 1 = Blueprint Review: Control measures are reasonably designed, but it has not been verified whether they are actually being executed.
  • Type 2 = Actual Acceptance: During an observation period, control measures are indeed effectively operating.
  • Mainstream cloud service providers (e.g., AWS, Azure, GCP) generally continuously produce SOC 2 Type 2 reports for enterprise customers to use in supplier risk assessments.

NIST CSF and NIST SP 800 Series

NIST CSF (Cybersecurity Framework)

A voluntary cybersecurity framework released by the US NIST (National Institute of Standards and Technology), widely applied across industries. CSF 2.0 (released in 2024) added the Govern function, emphasizing the governance level, defining six core functions, and providing a structured method for organizations to assess and improve their security posture.

FunctionEnglishDescriptionCorresponding Activities
GovernGovern (GV)Establish security governance structure and strategy to ensure security risk management aligns with organizational goals (Added in CSF 2.0)Security policy formulation, role and responsibility assignment, supply chain risk management
IdentifyIdentify (ID)Inventory organizational assets, business environment, and risksAsset management, risk assessment, supply chain identification
ProtectProtect (PR)Implement control measures to protect critical assetsAccess control, data security, security awareness training, platform security
DetectDetect (DE)Timely discovery of security incidentsContinuous monitoring, anomaly analysis, incident detection procedures
RespondRespond (RS)Take action on confirmed incidentsIncident management, analysis, notification, corrective actions
RecoverRecover (RC)Restore affected services to normalRecovery plan execution, improvement measures, external communication
Diagram

NIST CSF vs ISO 27001

  • NIST CSF: Voluntary framework, no certification system, focuses on "what to do" (function-oriented), suitable as a starting point for security maturity assessment.
  • ISO 27001: Can apply for third-party certification, focuses on "how to manage" (management system-oriented), suitable for organizations that need to prove compliance externally.
  • The two are complementary: Organizations can use NIST CSF to assess the gap between current status and goals, and then use ISO 27001 to establish a certifiable management system.
  • CSF 2.0 added the "Govern" function, emphasizing that security governance should be led by senior management, which is consistent with the spirit of ISO 27001 management review.

NIST SP 800 Series

A series of Special Publications released by NIST, covering technical guidance and control specifications for various security topics, primarily for US federal agencies as a basis for FISMA compliance, but also widely referenced by non-federal organizations.

DocumentTopicKey Description
SP 800-37Risk Management Framework (RMF)Defines a seven-step risk management process (Prepare, Categorize, Select, Implement, Assess, Authorize, Monitor), the primary compliance basis for federal agencies
SP 800-53Security and Privacy ControlsHundreds of control measures classified into 20 control families (e.g., AC Access Control, IR Incident Response), the implementation basis for SP 800-37
SP 800-61Computer Security Incident Handling Guide(Rev. 3, 2025) Incorporates incident response into the overall risk management context of CSF 2.0, with IR activities spanning all six Functions (Govern, Identify, Protect, Detect, Respond, Recover)
SP 800-63Digital Identity GuidelinesSpecifies Authenticator Assurance Levels (AAL), Identity Assurance Levels (IAL), and Federation Assurance Levels (FAL)
SP 800-88Guidelines for Media Sanitization(Rev. 2, 2025) Divides media sanitization into three levels: Clear / Purge / Destroy, providing a decision framework for choosing sanitization methods based on data sensitivity and device type
SP 800-171Protecting CUISecurity requirements for non-federal systems processing Controlled Unclassified Information (CUI), commonly used for government supply chain compliance
SP 800-207Zero Trust ArchitectureDefines seven Zero Trust Tenets and the PE/PA/PEP logical architecture components, providing a reference architecture for federal agencies to migrate to Zero Trust

NIST CSF vs SP 800 Series

  • CSF: Defines "what results to achieve" (high-level function-oriented), suitable for assessing and communicating security posture.
  • SP 800 Series: Defines "what specific controls and processes to implement" (detailed technical-oriented), suitable for federal compliance and detailed implementation planning.
  • The two are complementary: CSF is the map, and the SP 800 series is the construction specification for each region.

COBIT Governance Framework

COBIT (Control Objectives for Information and Related Technologies)

An IT governance framework released by ISACA, currently in version COBIT 2019. The core question is "Is IT doing the right things, and doing them compliantly?", aimed at management and auditors.

COBIT divides IT activities into two levels:

LevelEnglishDescription
GovernanceGovernanceSet direction, evaluate options, monitor execution, responsible by the board or senior management
ManagementManagementPlan, build, execute, monitor specific activities, responsible by IT management

Common use cases: IT auditing, SOX compliance (Sarbanes-Oxley Act), and combined with ISO 27001 as a reference for the governance layer.

ITIL Service Management Framework

ITIL (Information Technology Infrastructure Library)

An IT service management framework released by PeopleCert (formerly AXELOS), currently in version ITIL 4 (2019). The core question is "Is IT delivering services well and operating stably?", aimed at IT operations and service management teams.

ITIL 4 centers on the Service Value System (SVS), containing 34 management practices, divided into three categories by function:

CategoryDescriptionRepresentative Practices
General Management PracticesManagement activities common across the organizationRisk management, information security management, knowledge management
Service Management PracticesManagement activities specific to IT servicesIncident management, problem management, change enablement, service desk
Technical Management PracticesTechnology-oriented management activitiesInfrastructure management, deployment management

Intersection with security: Incident Management, Problem Management, Change Enablement (called Change Control in ITIL v3) processes overlap heavily with security incident handling and vulnerability patching processes.

COBIT vs ITIL

  • COBIT: IT governance framework, answers "Are we doing the right things?", aimed at management and auditors.
  • ITIL: IT service management framework, answers "Are we doing services well?", aimed at operations teams.
  • The two are parallel, with no hierarchical relationship. In practice, they can be used together: COBIT sets governance goals, and ITIL implements service processes.

GDPR and Taiwan PII Act Comparison Table

AspectGDPR (EU)Taiwan Personal Data Protection Act
ApplicabilityOrganizations processing PII of EU residents (no geographical limit, applies to Taiwan enterprises serving EU users)Public and non-public agencies collecting, processing, or using PII within Taiwan
PII DefinitionAny information that can directly or indirectly identify a natural personName, date of birth, ID number, etc., that can directly or indirectly identify an individual
Core PrinciplesLawfulness, fairness, transparency, purpose limitation, data minimization, accuracy, storage limitation, integrity and confidentialityLegitimate purpose, necessity principle, data subject consent (written consent as a principle)
Data Subject RightsAccess, rectification, erasure (right to be forgotten), portability, object to processing, restriction of processingQuery, review, copy, supplement, correct, stop collection/processing/use, delete
Data Breach NotificationNotify competent authority (DPA) within 72 hoursNo unified statutory time limit, notify as soon as possible according to competent authority requirements
Maximum Penalty€20,000,000 or 4% of global annual turnover (whichever is higher)Non-public agencies: Fine of up to NT$15 million
Data Protection Officer (DPO)Mandatory in specific casesNo mandatory requirement
Cross-border TransferMust ensure adequate protection level in the receiving country (e.g., SCCs Standard Contractual Clauses, adequacy decision)Must be based on specific purposes and protected by the laws of the receiving country, or obtain data subject consent

TIP

  • Extraterritorial effect of GDPR: The trigger condition is not "where the organization is," but "whether it actively provides services to EU residents or monitors their behavior" (GDPR Art. 3(2)). Practical judgment criteria include: whether local EU languages are provided, whether Euro payments are accepted, whether the EU market is explicitly mentioned in marketing, etc. If the service has no geographical identification mechanism and treats all regions equally, it depends on whether there is an "intent to actively reach EU users," not automatically applicable just because there are EU users.
  • "Right to be forgotten" and "Right to data portability" are the most obvious differences between GDPR and Taiwan's PII Act.
  • GDPR penalties are far higher than Taiwan's PII Act, so for enterprises with large operations in the EU, GDPR compliance usually has a higher priority.

Taiwan PII Act: Notification Obligation (Articles 8, 9)

The timing of notification when collecting PII depends on the collection method:

Collection MethodArticleNotification Timing
Direct Collection (obtained from the data subject, e.g., filling out a form)Article 8At the time of collection
Indirect Collection (obtained from someone other than the data subject, e.g., from a third party)Article 9At the time of first use of the PII

The notification content is the same for both cases: name of the collecting agency, purpose of collection, PII category, period/region/object/method of use, and rights that the data subject can exercise.

Advanced Privacy Concepts

Data Sovereignty: Data is subject to the laws of the country where it is stored. When an organization uses cloud services, if data is stored on servers in other countries, it may be subject to the laws of multiple countries simultaneously (e.g., the US CLOUD Act allows the US government to cross-border access data held by US companies).

DPIA (Data Protection Impact Assessment): GDPR Article 35 requires prior impact assessment for high-risk PII processing activities to identify privacy risks and develop mitigation measures. Although Taiwan's PII Act has no explicit DPIA article, competent authorities encourage organizations to conduct them voluntarily.

Data Minimization and Purpose Limitation

These are two core concepts among the eight GDPR principles most often related to "collecting PII":

PrincipleEnglishDefinitionCommon Violation Case
Data MinimizationData MinimizationCollect only the PII necessary to achieve a specific purpose; do not collect more or excessivelyRequiring ID number, occupation, annual income, etc., unrelated to the service when applying for membership
Purpose LimitationPurpose LimitationPII can only be used for the purpose stated at the time of original collection; it cannot be used for other purposesPhone numbers collected for "customer service needs" are used for marketing SMS
  • The two are complementary: Purpose limitation determines "where it can be used," and data minimization determines "how much can be collected."
  • Violating purpose limitation is usually more serious than violating data minimization because if data already collected is misused, it is difficult for the data subject to remedy.

PII Processing Roles

RoleEnglishTypical HolderResponsibility
Data ControllerData ControllerEnterprise or agency collecting PIIDecides the purpose and processing method of PII, bears primary legal responsibility externally
Data ProcessorData ProcessorEntrusted third-party vendorExecutes PII processing according to Controller instructions, must sign a Data Processing Agreement (DPA)

HIPAA Medical Data Protection Regulation

HIPAA (Health Insurance Portability and Accountability Act)

A US federal regulation from 1996 that mandates privacy and security protections for Protected Health Information (PHI) in the healthcare industry. Applicable entities fall into two categories:

  • Covered Entities: Healthcare providers, health insurance companies, health information exchange organizations.
  • Business Associates: Third-party vendors entrusted by Covered Entities to process PHI (e.g., cloud storage, billing system operators).
RuleEnglishCore Requirement
Privacy RulePrivacy RuleLimits the scope of PHI use and disclosure, patient authorization must be obtained; grants patients the right to access and correct their own data
Security RuleSecurity RuleMandates three types of protective measures for electronic PHI (ePHI): administrative (policies/procedures), physical (facility access control), and technical (encryption/access control)
Breach Notification RuleBreach Notification RuleePHI breaches must be notified to affected individuals and HHS within 60 days; single incidents involving 500 or more people must be notified to local media simultaneously

💡 Terminology Quick Check

  • PHI: Protected Health Information
  • ePHI: Electronic Protected Health Information
  • HHS: Department of Health and Human Services
  • HIPAA vs GDPR: HIPAA applies only to the healthcare industry and is a US regulation; GDPR applies across industries and covers all PII processing within the EU.

Major Frameworks and Regulations Quick Check

Framework/RegulationNatureFocusApplicable EntitiesMandatory?
ISO 27001Management System StandardInformation Security Management (ISMS)Universal (all industries)Voluntary (can apply for certification)
NIST CSFSecurity FrameworkSecurity Risk Management (Six Functions)Universal (US government priority)Voluntary
NIST SP 800 SeriesTechnical Guidance and Control SpecsDetailed implementation of various security topics (including 800-53 controls)US federal agencies (non-federal can reference)Mandatory for federal agencies
COBITGovernance FrameworkIT Governance and Control ObjectivesIT governance layer, auditorsVoluntary (often used as audit benchmark)
ITILService Management FrameworkIT Service Delivery and OperationsIT operations/service management teamsVoluntary
GDPRRegulationPersonal Data ProtectionOrganizations processing PII of EU residentsMandatory
Taiwan PII ActRegulationPersonal Data ProtectionAgencies and enterprises collecting/processing PII within TaiwanMandatory
HIPAARegulationMedical Health Information ProtectionUS healthcare industryMandatory
PCI DSSIndustry StandardCredit Card Transaction Data SecurityOrganizations handling credit card transactionsMandatory (required by card organizations)
  • ISO 27001 vs NIST CSF: 27001 has a third-party certification system; CSF has no certification and focuses on maturity assessment.

Information Security Responsibility Level Operations Requirements Table (A to E Levels)

Responsibility levels decrease from A to E, with Level A being the most stringent and Level E the most lenient.

Item / Responsibility LevelLevel ALevel BLevel CLevel DLevel E
Dedicated Security Personnel4+2+1+0 (concurrently held by IT staff)0 (concurrently held by general staff)
ISMS CertificationEntire agency mandatory third-party verificationCore systems should pass third-party verificationCore systems should pass third-party verificationSelf-handled according to competent authority regulationsSelf-handled according to competent authority regulations
SOC (Security Operations Center) MonitoringMust be built, 24/7 uninterrupted monitoring for the entire agencyMust be built for core systemsCan be built based on agency scale and risk needsNoneNone
Vulnerability ScanningOnce a year (entire agency)Once a year (core systems)Once a year (core systems)Once every 2 yearsNone
Penetration TestingOnce every 2 yearsOnce every 2 yearsOnce every 2 yearsNoneNone
Security Health CheckOnce a yearOnce a yearOnce every 2 yearsNoneNone
Security Training (hours/year)Dedicated personnel: 12 hoursDedicated personnel: 12 hoursDedicated personnel: 12 hoursConcurrent IT personnel: 3 hoursGeneral concurrent staff: 3 hours

TIP

  • A vs B: The difference in ISMS certification and SOC monitoring is the scope; Level A covers the entire agency, while Level B only targets core systems.
  • Level C is the watershed: The minimum threshold for penetration testing and security health checks; neither exists from Level D onwards.
  • Level D onwards switches to concurrent system: No dedicated security personnel, concurrently held by IT staff, vulnerability scanning reduced to once every 2 years.
  • E vs D: Vulnerability scanning is still once every 2 years at Level D, and only completely canceled at Level E; concurrent personnel also downgraded from IT staff to general staff.

Risk Management

Differences between Vulnerability, Threat, and Risk

TermEnglishDescriptionAnalogy
VulnerabilityVulnerabilityA flaw in a system or process that can be exploitedThe door lock is broken
ThreatThreatAn event or actor that could exploit a vulnerability to cause damageA thief is active in the area
RiskRiskThe likelihood and impact of a threat exploiting a vulnerabilityThe probability and loss of being breached
  • Risk = Threat × Vulnerability × Asset Value. If any factor is zero, the risk does not exist; if any factor is reduced, the overall risk decreases accordingly.
Diagram

Risk Assessment and Treatment Detailed Process

Diagram
StageInputActivityOutput
Asset IdentificationOrganizational structure, business processesInventory and classify information assetsAsset inventory, asset value
Threat/Vulnerability IdentificationAsset inventory, threat intelligenceIdentify applicable threats and existing vulnerabilitiesThreat list, vulnerability list
Risk AnalysisThreats, vulnerabilities, existing controlsAssess risk likelihood and impactInherent risk, residual risk
Risk AssessmentRisk value, risk appetiteDetermine risk acceptabilityRisk level, treatment priority
Risk TreatmentUnacceptable risksSelect and implement treatment measuresRisk treatment plan, control measures

Risk Analysis Method Comparison

AspectQualitative AnalysisSemi-Quantitative AnalysisQuantitative Analysis
Output FormatLevel description (e.g., High/Medium/Low, Risk Matrix)Relative score (Likelihood score × Impact score)Financial value (e.g., ALE = 120k/year)
Data RequirementExpert judgment, questionnaires, interviewsExpert judgment + rating scaleHistorical event data, statistical models
Analysis DifficultyLowerMediumHigher, requires statistical and financial analysis skills
SubjectivityHigh (depends on assessor experience)Medium (mapping levels still has subjectivity)Low (calculated based on data)
Typical MethodRisk Matrix (Likelihood × Impact), Delphi MethodScore Matrix (High=5, Medium=3, Low=1 multiplied for ranking)ALE formula, Monte Carlo Simulation, FAIR model
Applicable ScenarioPreliminary screening, rapid classification when resources are limitedLacks historical data but needs cross-project ranking comparisonWhen financial decision basis is needed (e.g., ROSI analysis)

Combining Qualitative and Quantitative Analysis

In practice, qualitative analysis is often used to quickly screen high-risk items, and then quantitative analysis is performed on these items to produce financial data. Pure quantitative analysis is uncommon because it is difficult to obtain reliable historical occurrence rate data for many risks.

Risk Matrix

Presents Likelihood and Impact in a two-dimensional matrix; the intersection determines the risk level, assisting in prioritizing treatment. It is a qualitative tool, outputting level labels, and does not involve financial values.

Likelihood ↓ / Impact →LowMediumHigh
HighMediumHighHigh
MediumLowMediumHigh
LowLowLowMedium

Delphi Expert Assessment Method

A structured expert consensus method used for risk assessment scenarios that lack historical data and must rely on expert judgment.

  1. Send anonymous questionnaires to experts to collect individual opinions.
  2. Summarize statistics and provide feedback to all experts.
  3. Experts revise their own judgments based on group feedback.
  4. Repeat iterations until opinions converge to a consensus.

The anonymous design aims to eliminate bandwagon effects and authority influence, ensuring each expert's judgment is independent.

Score Matrix Method

A semi-quantitative analysis tool that maps qualitative levels to organization-defined numerical values and multiplies them to produce a risk priority score. A common example is High=5, Medium=3, Low=1, but both the values and the number of levels can be adjusted according to needs; the scale must remain consistent within the same assessment.

Risk Priority = Likelihood Score × Impact Score, the result is only for relative ranking and does not represent the actual loss amount.

Risk Matrix vs Score Matrix

Both structures are the same (Likelihood × Impact), the difference is in the output format:

  • Risk Matrix (Qualitative): Outputs level labels (High/Medium/Low), used for rapid classification
  • Score Matrix (Semi-quantitative): Outputs numerical scores, used for cross-project priority comparison

Risk Quantification Formula

TermChineseDescription
ALE (Annualized Loss Expectancy)Annualized Loss ExpectancyAverage expected loss amount due to a specific threat within one year, ALE=ARO×SLE
ARO (Annualized Rate of Occurrence)Annualized Rate of OccurrenceExpected number of times a threat event occurs within one year (e.g., 0.1 = once every 10 years)
SLE (Single Loss Expectancy)Single Loss ExpectancyExpected loss amount each time a threat event occurs, SLE=AV×EF
AV (Asset Value)Asset ValueMonetary value of the asset
EF (Exposure Factor)Exposure FactorPercentage of asset loss when a threat occurs (0–100%)

Formula Connection

ALE=ARO×SLE

SLE=AV×EF

ALE=ARO×AV×EF

Example: Server value 1 million (AV), estimated loss of 60% after being encrypted by ransomware (EF = 0.6), estimated occurrence once every 5 years (ARO = 0.2). → SLE = 1 million × 0.6 = 600,000 → ALE = 0.2 × 600,000 = 120,000/year

If the annual cost of protective measures is less than 120,000, it is cost-effective.

Diagram

Monte Carlo Simulation and ALE

The traditional ALE formula assumes ARO and EF are fixed values, but in reality, these parameters have uncertainty ranges (e.g., "occurs every 3–7 years"). Monte Carlo simulation performs massive random sampling, taking possible values for each variable, executing tens of thousands of calculations, and producing a probability distribution of ALE rather than a single number, which is the standard method for advanced Quantitative Risk Analysis (QRA).

For example, the output: "There is a 90% probability that the annualized loss will not exceed 500,000," which is more valuable for decision-making than "expected loss of 200,000."

ROSI (Return on Security Investment)

ROSI measures the financial rationality of security control measures: how much loss can the investment save?

ROSI=(ALEbeforeALEafter)Annual Cost of Control MeasureAnnual Cost of Control Measure×100%
TermDescription
ALE_beforeAnnualized Loss Expectancy before implementing control measures
ALE_afterAnnualized Loss Expectancy after implementing control measures (after risk reduction)
Annual Cost of Control MeasureTotal cost of ownership of the security measure per year (license fees + manpower + maintenance)

Example: Antivirus software annual fee 20,000, expected to reduce ALE from 150,000 to 30,000.

  • Loss saved: 150,000 − 30,000 = 120,000
  • Net benefit: 120,000 − 20,000 = 100,000
  • ROSI = 100,000 / 20,000 × 100% = 500% (every 1 unit invested saves 5 units of loss)

FAIR Model (Factor Analysis of Information Risk)

FAIR is the industry-mainstream quantitative risk analysis framework, an open standard maintained by The Open Group, which decomposes risk into a quantifiable factor tree structure, ultimately producing a probability distribution of loss.

Diagram
TermDescription
Loss Event Frequency (LEF)Expected number of times a threat successfully results in loss within a certain time
Threat Event Frequency (TEF)Frequency of threat attempts (regardless of success or failure)
VulnerabilityProbability that a threat event converts into a loss event (the stronger the control measure, the lower this value)
Loss MagnitudeImpact scale of a single loss event, decomposed into primary loss and secondary loss (e.g., reputation damage, legal litigation)

FAIR vs Traditional ALE

  • The ALE formula is a "point estimate," while FAIR produces a conclusion of "X% probability that loss will not exceed Y amount" through factor decomposition and probability distribution, leading to higher decision quality.
  • FAIR and ISO 27005, NIST CSF can be used complementarily: ISO 27005 defines the risk management process, and FAIR provides quantitative analysis methods.
  • Implementation threshold: Requires collecting fine-grained threat and control measure data, suitable for organizations with higher security maturity.

Risk Treatment Strategy Comparison Table

Strategy (ISO 27005)EnglishDefinitionExampleApplicable Scenario
Risk AvoidanceRisk AvoidanceAbandon activities or assets that may trigger riskStop using insecure legacy protocols, abandon high-risk marketsRisk is too high and cannot be effectively reduced
Risk ModificationRisk ModificationImplement control measures to reduce risk likelihood or impactDeploy firewall, implement MFA, encrypt transmissionRisk is within acceptable range, and control measure cost is reasonable
Risk SharingRisk SharingShare part of the consequences of risk with third parties, usually part of financial impact or contractual liabilityPurchase cyber insurance, outsourcing (MSP/MSSP), SLA agreed compensation mechanismRisk impact is large, but impact can be dispersed through contracts or insurance
Risk RetentionRisk RetentionAcknowledge risk exists, take no additional measuresResidual risk is below risk appetite, patching cost far exceeds potential lossRisk is within tolerable range, or control cost is not cost-effective

ISO 27005 Risk Treatment Process

  1. Risk Assessment: Identification → Analysis → Evaluation.
  2. Based on assessment results, select treatment strategies (Avoidance/Modification/Sharing/Retention) for each risk.
  3. Develop a Risk Treatment Plan, recording selected strategies and implementation schedules.
  4. Residual Risk must be formally approved for acceptance by management.

Risk Terminology Supplementary Comparison Table

TermEnglishDefinition
Inherent RiskInherent RiskRisk level before implementing any control measures, reflecting the natural exposure of assets to threats
Residual RiskResidual RiskRemaining risk after implementing risk treatment measures, must be formally accepted by management
Secondary RiskSecondary RiskNew risks triggered by the risk response measures themselves (e.g., introducing monitoring systems to reduce security incident risk, but simultaneously creating employee privacy concerns)
Risk TransferRisk TransferTransferring specific parts of risk consequences to third parties through insurance, contracts, or compensation clauses
Risk AcceptanceRisk AcceptanceManagement is aware of and formally accepts risk, takes no further treatment measures, applicable when residual risk is within risk appetite
Risk CapacityRisk CapacityThe maximum loss limit an organization can bear without jeopardizing survival, an objective financial/operational boundary (different from risk appetite: the latter is subjective willingness, the former is objective capability)
Risk AppetiteRisk AppetiteThe upper limit of risk an organization strategically chooses to actively bear, a subjective willingness decision, must be lower than or equal to risk capacity
Risk ThresholdRisk ThresholdTrigger level for specific risks, requires immediate response when exceeded, usually lower than risk appetite

Risk Sharing vs Risk Transfer

ComparisonRisk SharingRisk Transfer
ISO 27005 Term✅ Official termCommon colloquialism, not an official ISO 27005 term
DefinitionShare risk consequences with third parties, usually part of financial loss, service level breach liability, or operational impactTransferring specific risk consequences to third parties through insurance or contracts, usually emphasizing the transfer of "financial burden"
Substantive DifferenceOriginal risk and governance responsibility remain with the organization, only shared consequences with third partiesSemantically stronger, but in practice usually only transfers part of financial consequences, does not mean legal responsibility disappears completely
ExampleOutsourcing: Service interruption loss shared by both parties according to SLA or compensation capPurchase cyber insurance: Insurance company absorbs part of the claim amount

The two are often used interchangeably in practice; ISO/IEC 27005 officially adopts Risk Sharing, while Risk Transfer is a more common colloquialism. Regardless of the term used, insurance or outsourcing contracts can only transfer part of the financial consequences; compliance obligations and legal responsibilities under GDPR, PII Act, etc., do not disappear because of this.

Risk Retention vs Risk Acceptance

ComparisonRisk RetentionRisk Acceptance
NatureRisk treatment strategy (one of four)Formal approval action by management
SourceISO 27005 treatment option list; ISO 27001 text does not list strategy namesISO 27001 Clause 6.1.3e directly requires; ISO 27005 explains process details
TimingAfter assessment, choose not to take additional control measuresAfter any treatment strategy is executed, formal sign-off on residual risk
RelationshipCan be established independentlyMust have corresponding risk acceptance after every treatment strategy is executed

The two can be established simultaneously: Choose "Risk Retention" (no treatment) → Residual risk equals inherent risk → Management executes "Risk Acceptance" for formal approval.

Hierarchical Relationship of Risk Appetite, Risk Capacity, and Risk Threshold

  • Risk Capacity: Objective upper limit, organization cannot survive if exceeded (e.g., total loss of net assets).
  • Risk Appetite: Subjective willingness, how much risk the organization strategically chooses to bear, must be ≤ Risk Capacity.
  • Risk Threshold: Trigger level for specific risks, requires immediate response when exceeded, usually lower than risk appetite.

Hierarchical order from high to low: Risk Capacity ≥ Risk Appetite ≥ Risk Threshold.

Relationship between Inherent Risk and Residual Risk

  • No control measure can reduce risk to zero; residual risk must be formally accepted by management.
  • Secondary risk is a link often overlooked in risk management plans: when assessing response measures, it is necessary to simultaneously identify whether new risks are introduced.

Shadow IT

Definition: Software, cloud services, or hardware devices adopted by employees or teams without approval from the IT department. Shadow IT is like an "underground market" in the office: employees bypass formal IT procurement to meet deadlines, buying SaaS with private accounts, opening cloud resources, or even pasting data into AI assistants. With the popularity of SaaS tools and the rise of AI services, the scope of Shadow IT has expanded significantly.

Common Types:

TypeDescriptionTypical Example
Shadow SaaSEmployees privately use unapproved SaaS toolsPersonal Google Drive, Dropbox, Notion
Shadow CloudEngineers open cloud resources with personal or credit card accounts, bypassing IT procurement processesSelf-built AWS accounts, Azure subscriptions
Shadow AIEmployees input company data into unapproved AI toolsPasting customer data or source code into ChatGPT, using unvetted AI Coding Assistants
Shadow DataData is copied to unmanaged storage locations, forming untracked data copiesExporting databases to personal NAS, forwarding email attachments to personal mailboxes
Shadow HardwarePhysical devices not registered with IT connected to the enterprise networkPersonal NAS, Raspberry Pi, undeclared routers

Common Risks:

RiskDescription
Data LeakageSensitive data enters unmanaged services; supplier terms may allow using data to train models (Shadow AI is particularly obvious)
Compliance ViolationData storage locations may violate data sovereignty or GDPR regulations
Lack of Patch ManagementSoftware not included in enterprise patching processes may have known vulnerabilities
Audit Blind SpotUnable to track data flow and usage records, difficult to trace after an incident
  • Countermeasures: CASB to detect unauthorized cloud services, SaaS management platforms, regular cloud usage inventory; provide approved alternatives to reduce employee motivation to bypass (employees often use Shadow IT because official tools are inefficient).
  • Intersection of Shadow IT and BYOD: Employees install unapproved work applications on personal devices, touching both issues simultaneously.

Incident Management

Information Security Incident Classification

ClassificationEnglishDescriptionExampleResponse Priority
Security EventSecurity EventState change identified in system or networkFirewall log denies connectionLow (record only)
Security AlertSecurity AlertNotification that may indicate a security eventIDS detects abnormal trafficMedium (needs analysis)
Security IncidentSecurity IncidentConfirmed violation of security policy or threatMalware infection, data leakageHigh (immediate response)
Major Security IncidentMajor IncidentIncident causing major impact on business operationsRansomware locking core systemsHighest (crisis management)

Inclusion Relationship of the Four

All incidents are events, but not all events are incidents. The four have a nested inclusion relationship, not a parallel classification:

Event ⊃ Alert ⊃ Incident ⊃ Major Incident

  • Event: Broadest scope, any observable system state change is an event, including massive normal logs.
  • Alert: Filtered from events as notifications requiring attention, still possibly a False Positive.
  • Incident: Confirmed violation of security policy after analysis, upgraded to incident, requiring formal response.
  • Major Incident: A subset of incidents affecting business operations, requiring the initiation of crisis management processes.

Information Security Incident Severity Classification Comparison Table (Levels 1 to 4)

The higher the number, the more severe the information security incident.

Item / Severity LevelLevel 1Level 2Level 3Level 4
Judgment Criteria (Core Logic)Non-core system interruption, no PII or confidential data leakageNon-core system paralysis, or involvement of general PII leakageCore system paralysis, data tampering, or sensitive PII leakageNational security threatened, critical infrastructure large-scale shutdown
Notification Time LimitWithin 1 hourWithin 1 hourWithin 1 hourWithin 1 hour
Damage Control or Recovery OperationsWithin 72 hoursWithin 72 hoursWithin 36 hoursWithin 36 hours
Investigation, Handling, and Improvement Report Submission DeadlineWithin 1 monthWithin 1 monthWithin 1 monthWithin 1 month
Typical ExampleOfficial website graffiti, general office computer virus infectionCore business briefly interrupted, general PII leakageMedical record leakage, official document leakage, core system crashPower grid/water conservancy paralysis, military or diplomatic secret leakage

Taiwan Regulation Time Limit Supplement

According to the current "Regulations on Notification, Response, and Drills for Information Security Incidents," after completing damage control or recovery for incidents of all levels, investigation and handling should continue, and an investigation, handling, and improvement report should be submitted within 1 month.

Information Security Incident Response (NIST SP 800-61)

NIST SP 800-61 Rev. 3 (April 2025) positions incident response as a component of CSF 2.0 risk management, no longer presented as an independent "Incident Handling Manual." IR activities span all six Functions of CSF 2.0, with Govern and Identify as the governance foundation, Protect responsible for preparation and defense, Detect, Respond, and Recover responsible for actual incident handling; continuous improvement spans the entire IR lifecycle, no longer occurring only after the fact.

Chinese NameCSF 2.0 FunctionCore Task
GovernanceGovernEstablish IR policy, role assignment, authorization, and resource allocation
IdentificationIdentifyIdentify critical assets, assess threat scenarios, establish IR trigger conditions
ProtectionProtectDeploy detection tools, establish CSIRT, develop response plans and drills
DetectionDetectIdentify incidents through SIEM, IDS, and log monitoring, determine severity and impact scope
ResponseRespondContain affected systems, remove malware and vulnerabilities, execute communication and coordination
RecoveryRecoverRestore systems and verify normal operation, write incident reports, update response plans

Rev. 2 (2012) Four-Stage Lifecycle

Rev. 2 (revoked in April 2025) defined the incident handling lifecycle in four stages:

StageChinese NameEnglish NameCore Task
1PreparationPreparationEstablish CSIRT, develop response plans, deploy detection tools, conduct education, training, and drills
2Detection and AnalysisDetection & AnalysisIdentify incidents through SIEM, IDS, and log monitoring, determine incident severity and impact scope
3Containment, Eradication, and RecoveryContainment, Eradication & RecoveryIsolate affected systems (containment) → remove malware and vulnerabilities (eradication) → restore systems and verify normal operation (recovery)
4Post-Incident ActivityPost-Incident ActivityWrite incident reports, review improvement measures, update response plans, preserve evidence (for legal or audit purposes)

💡 Terminology Quick Check

  • CSIRT: Computer Security Incident Response Team
  • SIEM: Security Information and Event Management
  • IDS: Intrusion Detection System
Diagram

Incident Handling Priority

  • Containment is the first priority: isolate infected systems first to prevent disaster expansion, then perform eradication and recovery.
  • "Lessons Learned" in post-incident activities is key to continuous improvement; every incident should produce improvement suggestions fed back to the preparation stage.

Differences between CSIRT, CERT, and SOC

OrganizationFull NamePositioningScope of Responsibility
CSIRTComputer Security Incident Response TeamIncident response teamInternal security incident detection, analysis, containment, and recovery, can be permanent or temporary
CERTComputer Emergency Response TeamEmergency response centerNational or regional level, provides cross-organizational security incident coordination and early warning (e.g., TWCERT/CC)
SOCSecurity Operations CenterSecurity operations center24/7 continuous monitoring, handles daily alerts and incident classification, CSIRT handles incidents escalated by SOC
  • CERT often acts as a national-level coordination center (e.g., Taiwan's TWCERT/CC, US-CERT), while CSIRT tends to be an internal organizational team.
  • SOC focuses on daily monitoring and initial alert screening, while CSIRT focuses on in-depth incident investigation and response. The two often work together: SOC detection → escalation to CSIRT handling.

MTTD / MTTA / MTTR Incident Response Indicators

IndicatorFull NameDefinitionCalculation Method
MTTDMean Time To DetectAverage time from actual threat occurrence to incident detectionDetection time − Incident occurrence time
MTTAMean Time To AcknowledgeAverage time from alert trigger to analyst confirmation of takeoverTakeover time − Alert trigger time
MTTRMean Time To RespondAverage time from incident detection to completion of response (containment/eradication/recovery)Response completion time − Detection time

Timeline order: Threat occurrence → MTTD → Detection confirmation/Alert trigger → MTTA → Analyst takeover → MTTR → Resolution

  • Shortening MTTD is more critical than shortening MTTR: The longer an attacker lurks inside the organization (Dwell Time), the greater the scope of lateral movement and data theft.
  • Industry reference: Industry data shows that the global average Dwell Time has shortened from hundreds of days to about 10 days, but there is still room for improvement.
  • Practices to improve MTTD: SIEM correlation analysis, EDR (Endpoint Detection and Response), Threat Hunting.
  • Definition in these notes: MTTR start point is detection time, so MTTR covers MTTA (MTTA is a sub-interval of MTTR).
  • Another common definition: Some organizations define the MTTR start point as analyst takeover time, in which case MTTA and MTTR are non-overlapping continuous intervals, total response time = MTTA + MTTR.
  • Relationship with MTTP: MTTD/MTTA/MTTR are response indicators "after an incident occurs"; vulnerability management has another MTTP (Mean Time To Patch), measuring the average time from "vulnerability disclosure to completion of patching," which belongs to the pre-incident prevention stage KPI.

Post-Incident Report

ElementDescription
Incident TimelineComplete record of every time node from detection, notification, containment to recovery
Root Cause AnalysisTrace the root cause of the incident, rather than just describing surface symptoms
Impact ScopeAffected systems, number of data records, business interruption time
Corrective ActionsActions already taken (e.g., patching vulnerabilities, blocking accounts, updating rules)
Preventive RecommendationsLong-term improvement measures to prevent recurrence of similar incidents

Cross-Platform Log Management and Forensics Path

AspectWindowsLinux
System LogsEvent Viewer: Application, Security, System channels/var/log/syslog (Debian family) or /var/log/messages (RHEL family); systemd uses journalctl
Security/Auth LogsSecurity event records (Logon success 4624, Logon failure 4625, Account creation 4720)/var/log/auth.log (Debian) or /var/log/secure (RHEL)
Web Server LogsIIS: C:\inetpub\logs\LogFiles\Apache: /var/log/apache2/; Nginx: /var/log/nginx/
Firewall LogsWindows Firewall: Event Viewer Windows Firewall With Advanced Securityiptables: /var/log/kern.log; nftables: journalctl -k
Centralized ManagementWindows Event Forwarding (WEF)rsyslog / syslog-ng remote forwarding to SIEM
Log RetentionGPO setting Event Log size and overwrite policylogrotate setting rotation and retention days
Key EventsLogon failure (4625), Permission change (4672), Object access (4663)/var/log/auth.log, auditd rules
Anti-TamperingForward to SIEM and set to read-onlyRemote Syslog + chattr +a (append-only)
Windows / Linux Log Query Command Examples
powershell
# Windows: Query logon failure events (4625) from the last day
Get-WinEvent -FilterHashtable @{
  LogName = 'Security'
  Id = 4625
  StartTime = (Get-Date).AddDays(-1)
} -MaxEvents 20

# Windows: Query Security log directly with wevtutil, newest events first
wevtutil qe Security /c:20 /rd:true /f:text
bash
# Linux: View systemd journal from the last hour
sudo journalctl --since "1 hour ago"

# Linux: View logs from the previous boot cycle
sudo journalctl -b -1

# Linux: Set file to append-only, reducing risk of log overwriting
sudo chattr +a /var/log/auth.log
  • Get-WinEvent -FilterHashtable is suitable for precise filtering of events by LogName, Id, StartTime.
  • wevtutil qe is suitable for quick querying of Event Logs or exporting events.
  • journalctl -b -1 is commonly used to compare whether abnormalities appeared "before this boot."
  • chattr +a is a common practice for ext file systems, meaning the file can only be appended, not overwritten or deleted.

Log Management Key Comparison Table

AspectKey Description
Log PurposeRecord user activities and abnormal events, serve as post-incident tracking and legal evidence; protect Non-repudiation
Syslog ProtocolDefaults to UDP port 514 (unreliable, packets may be lost during high traffic); switch to TCP to ensure reliable delivery; use TLS (Syslog over TLS) for encrypted transmission
Centralized ManagementImport logs from multiple devices/systems into SIEM for unified querying and analysis
NormalizationLog formats (field names, time formats) from different devices are inconsistent, must be unified before centralized analysis
Clock Synchronization (NTP)Device clocks must be synchronized with a standard time source to ensure correct timing of cross-device logs, which is the basis for audit and judicial evidence
Protection and RetentionLogs must not be arbitrarily modified by administrators; retention period should meet regulatory or policy requirements

Syslog Severity Levels

LevelValueKeywordDescription
Emergency0EMERGSystem unusable (e.g., kernel crash)
Alert1ALERTImmediate action required (e.g., primary database unresponsive)
Critical2CRITCritical error (e.g., hardware failure)
Error3ERRGeneral error, troubleshooting required
Warning4WARNINGNot an error but an abnormal condition worth noting
Notice5NOTICENormal but important event
Informational6INFOGeneral informational message
Debug7DEBUGDetailed message for debugging, usually disabled in production

Common Log Formats

FormatDescription
Syslog (RFC 5424)Linux/Unix standard log protocol, includes Priority, Timestamp, Hostname, App-Name, Message structure
JSONStructured logs, convenient for parsing and querying by tools like ELK (Elasticsearch + Logstash + Kibana)
CEF (Common Event Format)Defined by HP ArcSight, semi-structured format widely supported by SIEM, fixed fields, easy to integrate across systems
LEEF (Log Event Extended Format)Structured format used by IBM QRadar, similar to CEF but field definitions differ slightly
W3C Extended Log FormatWeb server log standard, default for IIS

Easily Confused Concepts

  • Retaining logs protects Non-repudiation, not confidentiality or availability.
  • Syslog runs on UDP, packets may be lost during high traffic, which is a design characteristic of UDP not retransmitting.
  • Log formats from different devices are different, requiring Normalization, do not confuse with De-identification.

Log Management Best Practices

  • Should record: Logon success/failure, permission changes, data access, system errors, management operations.
  • Should not record: Passwords (including hashes), credit card numbers, PII (ID numbers, medical records), to avoid logs themselves becoming a source of data leakage.
  • Integrity protection: Logs should be Write Once Read Many (WORM) after being sent to prevent attackers from tampering with logs to cover intrusion traces.
  • Centralization: Centralize logs to SIEM or log platforms; logs scattered across hosts are difficult to correlate and analyze.
  • Retention period: Determined by regulations and policies (e.g., PCI DSS requires retention for at least one year, with the last three months immediately accessible).
  • Alert settings: Set real-time alerts for high-risk events (multiple logon failures, privileged account operations, access outside business hours).

Digital Forensics: Order of Volatility

When collecting digital evidence during incident response, evidence should be collected in order from most easily lost (most volatile) to most stable to prevent permanent loss of data after system reboot or power interruption. This principle originates from RFC 3227.

OrderData SourceVolatility
1CPU registers, CPU cacheHighest (disappears when power is off)
2Main memory (RAM)Extremely high (lost when powered off)
3Running processes, network connection status, routing tablesHigh
4Temporary files, paging file (Paging File / Swap)Medium-high
5Hard disk dataMedium (non-volatile, but may be overwritten by malware)
6Remote logs, SIEM dataLow
7Archived media (tapes, backup discs)Lowest
  • Live Forensics: Capture memory image (Memory Dump) without shutting down, then perform disk image (Disk Image).
  • Any operation on the system (e.g., executing tool programs) may change RAM content, so evaluate carefully before collecting evidence.
  • Write Blocker: Must avoid any writing to the target media during collection, common practices:
    • Hardware Write Blocker: External device, intercepts all write commands at the hardware level, connected between the target disk and the collection machine, preferred.
    • Forensic Boot Environment: Boot from USB into Kali Forensic mode or WinPE forensic environment, local disks are not mounted to avoid OS pollution of the disk.
    • Image to External Media: Use dd, FTK Imager, dcfldd to read the source and write the image to external media, the original disk is only read.

Disk Imaging Tool Comparison

ToolPlatformFeatures
ddLinux / macOSBuilt-in to system, bit-for-bit copy, no progress display, no built-in hash, syntax errors may overwrite source
dcflddLinuxForensic-enhanced version of dd (developed by US Department of Defense Computer Forensics Laboratory), supports calculating hash while copying, progress display, simultaneous writing to multiple targets
FTK ImagerWindows (GUI)From AccessData, can output E01 (Expert Witness) or AD1 format, built-in hash verification, supports preview while copying

Storage Media Space Structure and Hidden Data

After obtaining a disk image, investigators, in addition to existing files, will target the following areas to find hidden or residual data:

AreaDescriptionForensic Significance
Slack SpaceOS allocates storage space in fixed-size Clusters. If file size is not an integer multiple of clusters, the space between the "actual file end" and "cluster end" is Slack SpaceMay contain residual data (content of the previous file that used the cluster), even if the original file has been deleted or overwritten, fragments in Slack Space can still be read
Unallocated SpaceSectors in the file system not occupied by any existing files. After a file is deleted, the OS only marks the cluster as "available" and does not immediately clear the dataData can still be restored by forensic tools (e.g., Autopsy, FTK) before being overwritten by new files, commonly used to recover malicious programs or logs deleted by attackers

Windows Execution Trace Forensics (Registry and System Files)

Even if the program has been deleted, the following registry keys will retain execution records:

LocationDescription
Shimcache (AppCompatCache)HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\AppCompatCache, records program paths and timestamps that have been executed on the system (updated after reboot)
Amcache.hveC:\Windows\appcompat\Programs\Amcache.hve, records hashes, paths, and first execution time of installed or executed applications
Prefetch (.pf)C:\Windows\Prefetch\, records DLLs loaded when the program is first executed, retains execution count and last 8 execution times
MFT (Master File Table)Core metadata table of NTFS, records attributes of every file (size, timestamp, data location); even if the file is deleted, MFT records can still be read by forensic tools. Records the "current" state of the file, does not retain historical change sequences.
$UsnJrnl (Update Sequence Number Journal)Records the sequence of all file and directory change events within the volume (creation, deletion, renaming, data change, encryption, etc.), each record carries a USN sequence number and timestamp. Even if the target file has been deleted, the journal record still exists, making it the best source for tracking ransomware encryption behavior trajectories.
$LogFile (NTFS Transaction Journal)Records pending or completed NTFS metadata changes for system recovery of MFT consistency after a crash. Content is in units of transactions, can be used in forensics to restore recent MFT changes, but retention time is short (circular overwrite).
$BitmapRecords the allocation status of each cluster (0 = unused, 1 = allocated). Used in forensics to identify the scope of Unallocated Space, confirming which sectors might contain residual deleted data.
  • Forensic value of Shimcache / Amcache: Can prove that a specific executable once existed on the system and was executed, even if the attacker has deleted the file afterwards.
  • Prefetch is disabled by default on Windows Server (to improve I/O performance), and ransomware often disables Prefetch for anti-forensics.

Linux Digital Forensics Common Paths

/proc/[pid]/ is a virtual directory of Linux procfs, reflecting the runtime state of a specific process, common forensic paths are as follows:

PathContentForensic Use
/proc/[pid]/mapsVirtual memory layout of the process, including mapped file paths and dynamic link libraries (.so)Confirm which shared libraries the process loaded, can discover maliciously injected .so
/proc/[pid]/cmdlineCommand line arguments used when starting the processView process startup arguments, but cannot be read for terminated processes
/proc/[pid]/environEnvironment variables inherited by the processFind hardcoded keys or settings
/proc/[pid]/statusProcess status (PID, PPID, UID, GID, etc.)Confirm parent-child relationship and execution identity of the process
/proc/[pid]/fd/All file descriptors currently opened by the processView files or network connections currently being read/written by the process
~/.bash_historyShell history command record, written upon logoutRestore attacker operation sequence; attackers often clear with history -c or unset HISTFILE

Chain of Custody

Records the complete custody history of digital evidence from collection to court presentation, ensuring the integrity and legal validity of the evidence. Each transfer or access must be recorded:

ItemDescription
WhoIdentity of the person obtaining, transferring, or accessing
WhenPrecise timestamp
WhereLocation or storage position
WhatOperation content (e.g., creating disk image, transferring to forensic personnel)

If the chain of custody is broken (e.g., evidence was out of custody or access was not recorded), the court may not accept the evidence.

Hash Integrity Verification: When collecting evidence, immediately calculate a hash (usually SHA-256) for both the original media and the image, and record it in the chain of custody document. Subsequent forensic operations are performed on copies, and the hash is verified before each start. If the hash matches, it can prove to the court that the copy is bit-for-bit identical to the original media and has not been tampered with.

PlatformCommand
Linuxsha256sum disk.img
Windowscertutil -hashfile disk.img SHA256
Linux Log Search and Forensic Command Examples
bash
# Use journalctl to search for SSH events in a specific time range
journalctl --since "2025-01-01 00:00:00" --until "2025-01-02 00:00:00" -u sshd

# Search for SSH brute force (logon failure records)
grep "Failed password" /var/log/auth.log | tail -20

# Count source IPs of SSH logon failures (sorted by frequency)
grep "Failed password" /var/log/auth.log \
  | awk '{print $(NF-3)}' | sort | uniq -c | sort -rn | head -10

# Memory Dump — Using LiME kernel module
sudo insmod /opt/lime/lime-$(uname -r).ko "path=/evidence/mem.lime format=lime"

# Use dd to create bit-for-bit disk image
sudo dd if=/dev/sda of=/evidence/disk.img bs=4M status=progress

# Calculate hash of image file (ensure evidence integrity, maintain Chain of Custody)
sha256sum /evidence/disk.img > /evidence/disk.img.sha256
  • journalctl --since "2025-01-01 00:00:00" --until "2025-01-02 00:00:00" -u sshd is suitable for precise filtering of events by time and unit.
  • grep "Failed password" /var/log/auth.log is a classic way to quickly find brute force traces.
  • insmod is used to load the LiME kernel module for memory dumping.
  • dd is the standard tool for bit-for-bit disk imaging.
  • sha256sum is used to generate the hash for integrity verification.

Security Considerations for Log Recording

  • Prohibit recording sensitive data: Passwords, credit card numbers, personal ID numbers, etc., must not appear in logs.
  • Log integrity protection: Attackers often clear logs after intrusion to cover traces; logs should be forwarded in real-time to an independent SIEM or centralized log server.
  • Time synchronization: All systems should synchronize clocks via NTP to ensure the timeline of cross-system logs can be correctly correlated.
  • Log retention period: Set retention policy according to regulatory requirements (e.g., "Information Security Management Act" requires retention for at least 6 months) and business needs.

Memory Forensics

Memory (RAM) is the most volatile source of evidence, containing running processes, network connections, decrypted keys, and malicious code, which disappear permanently after shutdown. Volatility is the most mainstream open-source memory forensics framework, capable of analyzing memory images (Memory Dump) of Windows / Linux / macOS.

Core Analysis Targets:

Analysis TargetVolatility Common Commands (v3)Forensic Significance
Running Processeswindows.pslist / windows.pstreeList all processes and parent-child relationships, find malicious programs disguised as system processes (e.g., fake svchost.exe)
Network Connectionswindows.netstatList all TCP/UDP connections and corresponding processes, find abnormal C2 communication connections
Injected Malicious Codewindows.malfindScan memory segments with "Executable + Readable/Writable (RWX)" protection attributes and no corresponding disk file
DLL Listwindows.dlllistList all DLLs loaded by the process, find abnormally injected DLLs
Registry Hivewindows.hivelistList memory addresses of loaded Registry Hives, can further dump SAM / SYSTEM and other Hives

VAD (Virtual Address Descriptor) Tree Structure:

Windows kernel uses the VAD tree to record the memory segment allocation status and protection attributes of each process (e.g., PAGE_EXECUTE_READWRITE). When malicious code is injected (Process Injection, Process Hollowing), a memory segment with RWX (Read-Write-Execute) permissions is often allocated first, and then Shellcode is written; at this time, this memory segment exists in the VAD but has no corresponding physical disk file, which is a very obvious abnormal feature in the VAD tree and the main detection basis for windows.malfind.

Common Methods for Obtaining Memory Images

OSToolDescription
WindowsWinPmem, DumpIt, FTK ImagerCommercial or open-source tools, use kernel drivers to read physical memory and output raw / lime format
LinuxLiME (Linux Memory Extractor)Kernel module, loaded via insmod to dump memory to local or transmit over network
Virtual MachineHypervisor SnapshotVM snapshot directly contains memory state, easiest to obtain and cleanest for forensics

Business Continuity and Disaster Recovery

Backup Type Comparison Table

Backup TypeEnglishBackup ScopeBackup TimeRestore StepsStorage Space
Full BackupFull BackupAll data, regardless of whether it changed since the last backupLongest1 (Full is enough)Largest
Differential BackupDifferential BackupAll data changed since the last Full BackupIncreasing (larger later)2 (Latest Full + Latest Diff)Medium
Incremental BackupIncremental BackupData added or changed since the last any backupShortestMultiple (Latest Full + all subsequent Inc)Smallest

Backup Strategy Trade-offs

  • Full Backup = Slowest backup, simplest restore.
  • Differential Backup = Space larger than incremental, but restore only needs two copies (Full + Latest Diff).
  • Incremental Backup = Fastest backup each time, but requires chaining multiple copies during restore, most complex process.
  • Common strategy: Full backup on Sunday, Incremental (or Differential) from Monday to Saturday.
  • RPO (Recovery Point Objective): Maximum time range of data loss allowed, determined directly by backup cycle. Higher backup frequency, shorter RPO; Full backup combined with hourly Transaction Log can compress RPO to within 1 hour.
  • 3-2-1 Backup Rule: At least 3 copies, stored on 2 different media, 1 copy off-site. This is the industry-recognized minimum standard.
  • WORM (Write Once Read Many) Storage: Data cannot be modified or deleted within the specified retention period after being written, effectively resisting ransomware encryption or attackers deleting backups. Cloud services (e.g., Azure Immutable Blob Storage) support WORM mode, which is an important part of modern backup strategies.

SQL Server Backup Correspondence (Industry practical example):

General Backup TypeSQL Server CorrespondenceSQL Server Feature
Full BackupFull BackupBacks up the entire database, including data and part of transaction logs, can be restored independently
Differential BackupDifferential BackupBacks up data pages (Data Extent) changed since the last Full, restore requires Full + Latest Diff
Incremental BackupTransaction Log BackupBacks up transaction logs since the last log backup, restore requires Full + all subsequent Logs applied in order
  • SQL Server's Transaction Log Backup concept is equivalent to incremental backup, but records "transactions" rather than "changed files."
  • SQL Server also has "Filegroup Backup": Backs up only specific filegroups, suitable for ultra-large databases to avoid full database backup every time.
Diagram

Cross-Platform Backup Tool Comparison

AspectWindowsLinux
Built-in Backup Toolwbadmin (Windows Server Backup), File Historyrsync, tar, cp
Enterprise SolutionSQL Server Backup, Azure BackupBacula, BorgBackup, Restic
SnapshotVSS (Volume Shadow Copy Service)LVM Snapshot, Btrfs/ZFS Snapshot
Automatic SchedulingTask Schedulercron / systemd timer
Off-site BackupAzure Blob Storage, AWS S3rsync + SSH, rclone (supports multi-cloud)
Linux Backup Command Examples
bash
# rsync incremental backup (only transfers changed files, suitable for off-site backup)
rsync -avz --delete /var/www/ user@backup-server:/backup/www/

# tar full backup (compresses entire directory into a single file)
tar -czf /backup/full-$(date +%Y%m%d).tar.gz /var/www/

# Combined with cron to execute incremental backup daily at 2 AM
# crontab -e
# 0 2 * * * rsync -avz --delete /var/www/ user@backup-server:/backup/www/ >> /var/log/backup.log 2>&1

# Use find to clean up backup files older than 30 days
find /backup/ -name "full-*.tar.gz" -mtime +30 -delete
  • rsync is the standard for incremental synchronization.
  • tar is the standard for archiving and compression.
  • cron is the standard for scheduling.
  • find is the standard for file management and cleanup.
Windows Backup Command Examples
powershell
# wbadmin execute full backup to network share
wbadmin start backup -backupTarget:\\BackupServer\Share -include:C: -quiet

# Use robocopy to mirror sync folder (/MIR will sync delete extra files in destination)
robocopy C:\Data \\BackupServer\Data /MIR /Z /LOG:C:\Logs\backup.log

# Create VSS snapshot (Volume Shadow Copy)
vssadmin create shadow /for=C:
  • wbadmin is the built-in Windows Server backup tool.
  • robocopy is a powerful file copying tool, /MIR is essential for mirroring.
  • vssadmin is used to manage VSS snapshots.

RAID (Redundant Array of Independent Disks) Comparison Table

RAID LevelTechnical PrincipleMinimum DisksAllowable FailuresRead PerformanceWrite PerformanceAvailable SpaceApplicable Scenario
RAID 0Striping, no redundancy. Data is split and written alternately to each disk, all disk space is merged into a single logical disk volume20 (any disk failure results in total data loss)Highest (parallel read)Highest100% (sum of all disk capacities)Video editing scratch space, scenarios needing high performance but not fault tolerance
RAID 1Mirroring, data is completely copied to each disk2n-1 (as long as 1 disk remains)High (can read from both)No improvement (must write to both simultaneously)50%OS disk, scenarios valuing data security
RAID 5Striping + Distributed Parity, parity bits are rotated across different disks for each stripe31 (parity can rebuild one disk)HighDecreased (requires Parity calculation)(n-1)/nNAS (Network Attached Storage), common choice balancing performance and fault tolerance

RAID 5 Parity Distribution Illustration (3 Disks)

StripeDisk 0Disk 1Disk 2
1A1A2P(A)
2B1P(B)B2
3P(C)C1C2

P(X) = Parity block of the stripe (calculated via XOR). Parity bits for each stripe are rotated across different disks to avoid parity becoming a bottleneck on a single disk. When any disk fails, the lost block can be reconstructed by XORing the remaining data + parity (e.g., Disk 1 fails → A2 = A1 XOR P(A)).

Common RAID Misconceptions and Practical Configurations

  • RAID is not backup: RAID only prevents hard disk failure and cannot prevent ransomware encryption, accidental deletion, fire, etc.
  • Common industry combinations:
    • RAID 10 (1+0) = RAID 1 Mirroring + RAID 0 Striping. Balances performance and security, common choice for database servers (e.g., SQL Server recommends RAID 10 for data files).
    • RAID 50 (5+0) = RAID 5 + RAID 0. Commonly used in large storage systems.
  • Enterprise-grade storage usually pairs with Hot Spare disks, rebuilding automatically upon failure.

RAID 5 Intuitive Analogy

Imagine 3 notebooks to copy a story:

  • Notebook A writes paragraph 1, paragraph 2.
  • Notebook B writes paragraph 1, paragraph 3.
  • Notebook C writes paragraph 2, paragraph 3.

Each notebook rotates responsibility for writing the "summary page" (parity), recording the checksum value of the other two notebooks' content. If any one is lost, it can be restored from the content and summary page of the other two.

  • RAID 6 (Double Parity): Equals writing two summary pages per stripe, distributed on two different disks, thus can tolerate simultaneous failure of 2 disks. Requires at least 4 disks.
  • RAID 5 writes one parity bit, tolerates 1 failure; RAID 6 writes two parity bits, tolerates 2 failures, but write performance is lower (requires two Parity calculations).

Backup Site Type Comparison Table (Hot / Warm / Cold)

TypeEnglishEquipment StatusData Real-timeActivation TimeCost
Hot SiteHot SiteComplete equipment identical to main site, continuously runningReal-time sync (or extremely short delay)Within minutes (almost immediate switch)Highest
Warm SiteWarm SiteEquipment ready but standby, requires manual startup and data syncPeriodic backup (hours to a day)Hours to daysMedium
Cold SiteCold SiteOnly site, power, and basic infrastructure, no equipmentRequires restore from backup mediaDays to weeksLowest

RTO / WRT / MTPD / RPO

  • RTO (Recovery Time Objective): Maximum time service interruption is allowed after system shutdown. Hot Site RTO is shortest; Cold Site RTO is longest.
  • WRT (Work Recovery Time): Additional time required to verify data integrity, tune settings, and restore normal operations after system recovery (RTO achieved). Actual interruption time felt by users = RTO + WRT.
  • MTPD (Maximum Tolerable Period of Disruption): Absolute upper limit of interruption time the organization can bear. Exceeding this time will cause unacceptable business damage. MTPD ≥ RTO + WRT.
  • RPO (Recovery Point Objective): Maximum time range of data loss allowed after a disaster, determined by backup cycle. Hot Site (real-time sync) RPO is close to 0; Cold Site (periodic backup) RPO could be days ago.
  • Risk Appetite drives target setting: High risk appetite (can accept longer interruption) → Allows longer RTO/RPO → Can choose lower-cost backup solutions.
Diagram
  • RPO looks at the "past" (how much data can be lost), RTO + WRT looks at the "future" (how fast to recover), MTPD is the hard deadline.
  • Industry Practice: Core systems in the financial industry usually require RTO < 4 hours, RPO < 1 hour, so they mostly adopt Hot Site + real-time data sync (e.g., SQL Server Always On Availability Group).
  • General enterprise ERP systems can accept RTO < 24 hours, Warm Site combined with daily differential backup is sufficient.

Data Storage Tiering (Hot / Warm / Cold)

Distribute data to different cost storage tiers based on access frequency to achieve a balance between performance and cost.

TierCharacteristicsAzure Blob CorrespondenceTypical Data
Hot StorageHigh frequency access, low latency, high storage costHot tierRecent transaction records, current month reports
Warm StorageLow frequency access, lower storage cost, retrieval fee appliesCool tierHistorical data from the last one to three years
Cold StorageArchival use, retrieval takes hours, lowest costArchive tierOld data required by regulations, archival data older than three years

Data can be automatically downgraded over time (e.g., Azure Blob Lifecycle Management) or moved manually.

Relational Database Tiering Implementation

Relational databases (e.g., SQL Server) do not have native tiering management, usually implemented in the following ways:

  • Partition + Filegroup: Recent partitions are placed on SSD filegroups (Hot), old data partitions are placed on HDD filegroups (Cold), data is moved after aging using Partition Switching, without row-by-row copying.
  • Archival Database: Batch move data exceeding the retention period to an independent historical database, keep the main database lean, historical database is for query only.

Elasticsearch has native ILM (Index Lifecycle Management): Indices can be set to automatically move from Hot nodes (SSD, responsible for write and real-time query) to Warm nodes (HDD, read-only) and then to Cold/Frozen nodes, executed automatically by the engine without manual intervention.

Data Storage Tiering vs Backup Site: Same name, different meaning

"Hot/Warm/Cold" in backup sites refers to backup readiness (whether equipment is ready, how fast it can switch); in data storage tiering, it refers to the trade-off between access frequency and cost. The two sets of terms have the same name but independent concepts.

BCP Test Type Comparison Table

Test TypeEnglishDescriptionRiskCost
Tabletop ExerciseTabletop ExerciseSimulate disaster scenarios through meeting discussions, step-by-step review of plan proceduresNone (discussion only)Lowest
Structured Walk-ThroughStructured Walk-ThroughRepresentatives from each department jointly review plan content item by item, confirming roles and proceduresNoneLow
Simulation TestSimulation TestSimulate real disaster scenarios (e.g., simulate server room fire), execute notification and response processes, but do not actually switch systemsLowMedium
Parallel TestParallel TestBackup system actually starts and processes business, runs in parallel with main system to compare resultsLow (main system not interrupted)Medium-High
Full Interruption TestFull Interruption TestMain system completely shut down, all business switched to backup site for operationHighest (if backup fails, business is affected)Highest

TIP

  • Parallel Test: Backup system actually processes transactions while the main system is still online, verifying backup capability without affecting formal business.
  • Full Interruption Test is the only way to verify "true switching capability," but the risk is highest, usually executed only after approval by senior management.
  • Test frequency recommendation: Tabletop exercise once every six months, parallel/interruption test at least once a year.

Relationship between BCP and DRP

BCP (Business Continuity Plan) covers the complete strategy for an organization to maintain critical business operations during a disaster; DRP (Disaster Recovery Plan) is a subset of BCP, focusing on the technical recovery of IT systems and data. Both are formulated based on the analysis results of BIA.

Diagram
AspectBCPDRP
ScopeEntire organization (business processes, personnel, communication, IT)IT infrastructure (servers, network, data)
GoalMaintain minimum business operations during a disasterRestore IT systems to normal operating state
Key InputBIA (Business Impact Analysis)RTO / RPO targets from BIA, critical system list, backup architecture
Responsible RoleSenior management, business ownersIT department, security team

BIA (Business Impact Analysis) is executed before BCP/DRP formulation and is the common foundation for both. By analyzing the impact of interruption on various business processes, critical business functions are identified, and RTO, RPO, and backup priorities are set accordingly, serving as input for BCP strategy planning and DRP technical design.

Physical Security

Physical Security Control Measures Comparison Table

Control MeasureEnglishDescription
TailgatingTailgatingUnauthorized personnel following closely behind authorized personnel through access control, without independent card verification
PiggybackingPiggybackingAuthorized personnel knowingly and actively bringing in unauthorized personnel (e.g., "helping open the door")
MantrapMantrap / AirlockDouble-door interlocking design, the second door can only be opened after the first door is closed, forcing individual verification
CCTVCCTVClosed-circuit television monitoring, provides real-time monitoring and post-incident retrieval capabilities
Visitor ManagementVisitor ManagementVisitor registration, wearing identification badges, full escort, badge retrieval upon departure
Environmental ControlEnvironmental ControlsTemperature and humidity monitoring, fire suppression systems (FM-200 gas fire suppression), Uninterruptible Power Supply (UPS), backup generators
Cable ManagementCable ManagementNetwork line labeling and physical isolation, preventing unauthorized connection or eavesdropping

Tailgating vs Piggybacking

  • Tailgating: The followed person is unaware, a passive security vulnerability.
  • Piggybacking: The followed person is aware and actively cooperates, a behavior violating security policy.
  • Countermeasure: Mantrap can prevent both simultaneously because everyone must be verified independently.
  • Common protection combination for server rooms: Access card + Mantrap + CCTV + Visitor registration system.

Environmental Control and Fire Suppression Systems

Control ItemEnglishDescription
HVACHVAC (Heating, Ventilation, and Air Conditioning)Server rooms need to maintain 18–27°C, relative humidity 40–60%. Overheating causes equipment failure, high humidity causes condensation water to damage circuits.
Wet PipeWet PipePipes are pre-filled with water, sprays immediately when fire is detected. Fastest reaction but damages electronic equipment, not applicable to server rooms.
Dry PipeDry PipePipes filled with compressed air, injects water only when triggered. Suitable for low-temperature environments (anti-freeze), still sprays water, not applicable to precision equipment areas.
Pre-ActionPre-ActionCombines smoke and temperature dual detection, injects water only when both are triggered. Reduces risk of accidental spraying, applicable to areas outside the data center core.
Gas Fire SuppressionClean AgentUses inert gas or chemical gas (e.g., FM-200, Novec 1230, CO₂) instead of water. Non-conductive, leaves no residue, first choice for server rooms. CO₂ has suffocation risk, must be paired with personnel evacuation alarms.

Fire Suppression System Selection Basis

  • Office: Wet Pipe, lowest cost, fastest reaction.
  • Server room perimeter (occupied areas): Pre-Action, dual confirmation reduces accidental spraying.
  • Server room core (server area): Gas fire suppression (FM-200 / Novec 1230), does not damage equipment.
  • Unoccupied enclosed spaces: CO₂, strongest fire suppression effect but displaces oxygen, personnel must evacuate first.

Electromagnetic Shielding (TEMPEST)

TEMPEST is the electromagnetic leakage protection standard defined by the US NSA (Transient Electromagnetic Pulse Emanation Standard). Electronic equipment generates electromagnetic radiation (Emanation) during operation, which attackers can capture from a distance using high-sensitivity receivers to reconstruct screen images or keyboard input.

Protection MeasureDescription
Faraday CageEnclose space with conductive materials (metal mesh, metal plates) to block electromagnetic waves from entering or leaving. Server room level requires integration of walls, floors, and ceilings, and all incoming/outgoing lines must pass through filters.
TEMPEST Certified EquipmentEquipment itself reduces electromagnetic radiation from the design stage, meeting NSA certification standards (e.g., NSTISSAM TEMPEST/1-92).
Distance ControlLimit the distance between sensitive equipment and building exterior walls (Zone control), utilizing the characteristic that electromagnetic signals attenuate with distance.
White Noise GeneratorEmits random electromagnetic signals to cover equipment radiation, interfering with the attacker's signal capture.

TIP

  • TEMPEST guards against passive eavesdropping, where the attacker does not need to contact the target equipment.
  • Daily applications of Faraday cages: microwave oven shells, mobile phone signal shielding bags, MRI rooms.
  • Paired with cable management: Fiber optics do not radiate electromagnetic waves and are the preferred transmission medium for high-security environments.

Cable Management Practices

ItemDescription
Structured CablingFollow TIA/EIA-568 standard, distinguish horizontal cabling and backbone cabling.
Labeling SystemEach line end labeled with a unique identifier, corresponding to the Patch Panel Diagram, ensuring traceability.
Physical IsolationPower lines and data lines run in separate cable trays to avoid EMI (Electromagnetic Interference). Copper cables and fiber optics managed separately.
Locked Wiring ClosetWiring closets (IDF, Intermediate Distribution Frame) should be locked and controlled to prevent unauthorized connection or eavesdropping.
Fiber Optic Anti-EavesdroppingFiber optics do not radiate electromagnetic waves, eavesdropping requires physical bending of the fiber (Fiber Tapping), can be detected by optical power meters detecting abnormal attenuation.

Media Sanitization

When devices are scrapped or replaced, only formatting or deleting files cannot completely clear data, and corresponding destruction methods must be chosen based on media type:

MethodHDD (Traditional Magnetic Hard Disk)SSD / Flash Storage
Degaussing✅ Effective (destroys magnetic recording)❌ Ineffective (Flash does not rely on magnetism, degaussing cannot clear data)
Overwrite / Wipe✅ Effective (still a common Clear method for HDD, but should follow current standards and organizational procedures)⚠️ Partially effective (SSD wear leveling may retain old data blocks, requires vendor-supported secure erase commands)
ATA Secure Erase✅ Effective✅ Effective (if supported by vendor, controller ensures complete clearing)
Cryptographic Erase✅ Effective✅ Effective (encrypt all data first, then destroy the key, data becomes unreadable, recommended method for SSD)
Physical Destruction✅ Most thorough✅ Most thorough (NSA requires grinding to ≤ 2mm fragments)

NIST SP 800-88 Rev. 2 "Guidelines for Media Sanitization" (September 2025) divides media sanitization into three levels:

LevelDescriptionApplicable Scenario
ClearLogical clearing (overwrite), no special equipment requiredGeneral confidential data, replaced for reuse within the organization
PurgeDegaussing, ATA Secure Erase, NVMe Sanitize, or compliant cryptographic erase; can resist laboratory-level recovery attacksSensitive data, device moves outside organizational control
DestroyPhysical destruction, ensuring data is completely unrecoverableTop secret level, media must be completely scrapped
  • Cryptographic Erase reaches Purge level conditions: encryption enabled from device configuration, uses NIST-approved algorithms like AES-256, key destruction is verifiable; if any condition is not met, it only reaches Clear level.

Common Misconceptions

  • SSDs cannot rely on degaussing, cryptographic erase or physical destruction should be prioritized.
  • "Formatting" ≠ "Clearing": Formatting only deletes file indices, the data itself remains and can be restored by forensic tools.

SP 800-88 Rev. 1 (2014) Background

  • Rev. 1 directly listed technical operation details (e.g., "HDD overwrite with all zeros at least once"), widely cited for years.
  • Rev. 2 shifts from "operation manual" to a "framework for establishing organizational-level media sanitization programs," with most technical details now referencing IEEE 2883, NSA specifications, or organization-approved standards.
  • Rev. 2 adds NVMe-specific guidance and explicitly specifies conditions for cryptographic erase to reach Purge level (resolving the ambiguity of Rev. 1).

Network Security

Network Attack Four Basic Types Comparison Table

Based on the CIA triad, network attacks can be divided into four basic types:

TypeDamaged AttributeDescriptionTypical Technique
InterruptionAvailabilityData is cut off during transmission, cannot reach destinationDDoS, cutting physical lines
InterceptionConfidentialityEavesdropped during transmission, content leaked but transmission unaffectedPacket Sniffing, MITM eavesdropping
ModificationIntegrityData modified by unauthorized party before being sent, receiver unawareMITM packet tampering, SQL Injection
FabricationAuthenticityForged identity or data, pretending to be someone else to sendIP Spoofing, phishing emails

TIP

  • Interruption → You don't receive it (Availability destroyed).
  • Interception → You received it, but the content was seen (Confidentiality destroyed).
  • Modification → You received it, but the content was changed (Integrity destroyed).
  • Fabrication → You received it, but the sender is fake (Authenticity destroyed).

Network Architecture and Protocol Comparison Table

OSI 7 Layers Responsibilities

OSI LayerEnglishPDUResponsibilityCommon Protocols & Technologies
L7 ApplicationApplicationDataFaces users or applications directly, provides network service interface (e.g., browsing web, transferring files).HTTP/HTTPS, FTP, DNS, DHCP, SSH
L6 PresentationPresentationDataResponsible for data format conversion, encryption/decryption, compression, ensuring different systems can understand data formats.SSL/TLS, JPEG, Base64
L5 SessionSessionDataEstablishes, manages, terminates sessions between two ends, handles connection synchronization and dialog control.NetBIOS, RPC
L4 TransportTransportSegment/DatagramProvides reliable or fast end-to-end (Port to Port) transmission, responsible for flow control and error recovery.TCP (reliable), UDP (low latency)
L3 NetworkNetworkPacketResponsible for logical addressing (IP address) and routing across networks, determines best path from source to destination.IP (IPv4/v6), ICMP, BGP, OSPF
L2 Data LinkData LinkFrameResponsible for physical addressing (MAC address) within the same network, frame encapsulation, and error detection, controls data transmission between nodes.Ethernet (MAC), ARP, VLAN, PPP
L1 PhysicalPhysicalBitDefines electrical, optical, or wireless signal specifications of physical transmission media, responsible for sending and receiving raw bit streams.1000BASE-T, Wi-Fi RF, fiber optics, coaxial cable

TCP/IP Model vs OSI Comparison

The TCP/IP model has two versions: the "classic 4-layer" and the "modern practical 5-layer." The early one defined by the US Department of Defense (DoD) is 4 layers (RFC 1122). With the development of network hardware technology, mainstream textbooks and network management certifications (e.g., Cisco CCNA) generally adopt the 5-layer model (also called the hybrid model).

OSI LayerTCP/IP 4 Layers (Classic DoD)TCP/IP 5 Layers (Modern Practical)
L7 App / L6 Pres / L5 SessApplicationApplication
L4 TransportTransportTransport
L3 NetworkInternetNetwork
L2 Data LinkNetwork AccessData Link
L1 Physical⬆️ (Merged into Network Access)Physical

OSI and TCP/IP Layer Comparison Diagram

Diagram

TIP

  • Merging reasons: L5~L7 merged because modern applications handle connection, encryption, and business logic directly; L1~L2 merged because physical network cards and drivers usually operate bound together.
  • PDU and debugging correspondence: Find Port number → Check L4 (Wireshark); Find IP address → Check L3 (Ping, routing table); Find MAC address → Check L2 (Switch, VLAN).
  • TCP protocol vs TCP/IP model: TCP is a single transport protocol at L4; TCP/IP is the collective name for the entire L1~L7 internet communication architecture, even if the underlying layer uses UDP, it still runs within the TCP/IP model framework.
  • For the complete encapsulation/decapsulation process of each layer's PDU, see the PDU Comparison Table.

💡 Protocol Abbreviation Quick Check

Protocol Number is located in the L3 IPv4 header, identifying the upper-layer protocol used by the Payload (different from the L4 Port number, which identifies the application).

Protocol NumberProtocolDescription
1ICMPNetwork diagnostics and error reporting (ping uses this protocol)
6TCPReliable transmission, has handshake and retransmission mechanisms
17UDPLow latency transmission, no connection guarantee
47GREVPN tunnel encapsulation protocol
50ESPIPsec encrypted packet (common in VPN)
51AHIPsec authentication header, verifies only, does not encrypt
89OSPFInternal dynamic routing protocol

Other Protocol Abbreviations

AbbreviationFull NameChinese
ARPAddress Resolution ProtocolAddress Resolution Protocol
BGPBorder Gateway ProtocolBorder Gateway Protocol
802.1QVLAN encapsulation standard, adds VLAN Tag to Ethernet frame (VLAN is a technical concept, 802.1Q is the implementation protocol)
PPPPoint-to-Point ProtocolPoint-to-Point Protocol, used for identity authentication and line establishment for point-to-point connections, modern broadband internet (PPPoE) still uses its variants
RPCRemote Procedure CallRemote Procedure Call, allows programs to call functions on a remote server as if calling local functions, gRPC is the modern mainstream implementation
NetBIOSNetwork Basic Input/Output SystemNetwork Basic Input/Output System, underlying protocol for early Windows Network Neighborhood, should be disabled in modern environments

NetBIOS Security Risks

NetBIOS is an extremely outdated protocol, and it is strongly recommended to disable it completely in modern enterprise networks because:

  • Generates massive broadcast traffic in the internal network, consuming bandwidth.
  • Attackers can use NBT-NS Poisoning to spread laterally in the enterprise internal network, a common penetration technique for ransomware.
  • Modern Windows file sharing has switched to the more secure SMB (Port 445) and no longer needs NetBIOS.

PDU (Protocol Data Unit) Comparison Table

OSI LayerPDUEnglishDescription
L5-L7 ApplicationDataData / MessageRaw data generated by the application, not yet added with any protocol header.
L4 TransportSegment / DatagramSegment (TCP) / Datagram (UDP)TCP cuts data into segments and numbers them to ensure reliable transmission and order; UDP does not guarantee order or retransmit.
L3 NetworkPacketPacketAdds source/destination IP address, determines routing path.
L2 Data LinkFrameFrameAdds source/destination MAC address and FCS (Frame Check Sequence) error check code.
L1 PhysicalBitBitElectrical signals, optical signals, or radio waves.

Encapsulation and Decapsulation

Imagine the process of mailing a package: you put the document (Data) into an envelope, write the recipient Port (L4), then put it into an outer box with an address (L3 plus IP), and finally hand it to the courier truck (L2 converted to frame, L1 converted to electrical signal). Each extra layer is called "Encapsulation"; the recipient side拆開 (decapsulates) each layer in order.

Encapsulation order: Data → Segment / Datagram → Packet → Frame → Bit

Segment is the packaging unit for TCP, Datagram for UDP.

TCP and UDP

TCP and UDP are both L4 transport protocols, determining "how" data is sent, regardless of "where" it is sent (that is the job of L3 IP).

AspectTCPUDP
Full NameTransmission Control ProtocolUser Datagram Protocol
Connection ModeConnection-oriented (establishes connection before sending data)Connectionless (sends directly)
ReliabilityGuaranteed delivery: sequence numbers, acknowledgments, timeout retransmissionNot guaranteed: packets may be lost or out of order
SpeedSlower (extra overhead for handshake and acknowledgment)Faster (no handshake and acknowledgment)
Common ApplicationsHTTP/HTTPS, SSH, SMTP, FTPDNS query, VoIP, streaming media, QUIC

TCP Three-way Handshake

TCP must complete three steps before sending data to confirm both sides can send and receive:

Diagram

Common TCP Flags

FlagDescription
SYNRequest to establish connection
ACKAcknowledgment received
FINRequest to terminate connection normally
RSTForce reset connection (abnormal interruption)
PSHRequest immediate delivery to application layer, do not wait for buffer to fill

Security Relevance

  • SYN Flood: Attacker sends massive SYN but intentionally does not complete the handshake, exhausting the server's half-open connection table, a DoS attack.
  • TCP RST Injection: Attacker forges RST packets to force interruption of legitimate connections, can be used to interfere with communication or censorship (commonly used by firewalls to block).
  • UDP Amplification: UDP connectionless nature allows attackers to forge source IPs, using services with responses far larger than requests (e.g., DNS, NTP) to amplify attack traffic, see L3-L7 Denial of Service Attack section.

Common Port Comparison Table

Port numbers are located in the L4 TCP/UDP header, used to identify which application the packet should be handed to. For example, when a browser connects to a server, the server uses Port 80 or 443 to receive the request, letting the OS know to hand the traffic to the web service rather than other programs.

Port numbers are divided into three categories based on range:

RangeEnglish NameChinese NameDescription
0–1023Well-Known PortsWell-Known PortsOfficially assigned by IANA to common services, binding to this range on Linux/Unix requires root privileges
1024–49151Registered PortsRegistered PortsThird-party applications register with IANA for use, e.g., MySQL (3306), RDP (3389)
49152–65535Ephemeral PortsDynamic PortsTemporary ports dynamically allocated by the OS to clients, released after connection ends

IANA (Internet Assigned Numbers Authority)

Responsible for managing global internet number resources, including the allocation and registration of IP addresses, AS numbers, and Port numbers.

Developers usually do not need to apply to IANA for Port numbers; Ports within the Ephemeral Ports range can be used freely. Situations requiring application: developing a protocol or service intended to be public and become an industry-wide standard, then you need to apply to IANA for a fixed Registered Port so other people's systems can identify which service the Port belongs to.

Common Service Ports

PortProtocolTransport LayerDescription
20FTP-DATATCPFTP data transmission
21FTPTCPFTP control connection
22SSHTCPEncrypted remote login and file transfer (SCP/SFTP)
23TelnetTCPPlaintext remote login, deprecated and insecure
25SMTPTCPEmail transmission (server-to-server)
53DNSTCP/UDPDomain name resolution (UDP for query, TCP for zone transfer)
67/68DHCPUDP67 for server side, 68 for client side, dynamic IP allocation
80HTTPTCPPlaintext web transmission
110POP3TCPEmail retrieval (deleted from server after download)
143IMAPTCPEmail retrieval (mail retained on server)
161/162SNMPUDP161 for query, 162 for Trap (active alert)
389LDAPTCPDirectory service query (plaintext)
443HTTPSTCPTLS encrypted web transmission
445SMBTCPWindows file sharing and Network Neighborhood
465SMTPSTCPSMTP over TLS (encrypted email transmission)
514SyslogUDPSystem log transmission (plaintext, unreliable)
587SMTP SubmissionTCPEmail client submission (requires authentication)
636LDAPSTCPLDAP over TLS (encrypted directory query)
853DoTTCPDNS over TLS (encrypted DNS query)
993IMAPSTCPIMAP over TLS
995POP3STCPPOP3 over TLS
1433MSSQLTCPMicrosoft SQL Server
1521Oracle DBTCPOracle Database
3306MySQLTCPMySQL / MariaDB Database
3389RDPTCPWindows Remote Desktop Protocol
5432PostgreSQLTCPPostgreSQL Database
6379RedisTCPRedis cache database (no authentication by default, do not expose directly)
8080HTTP AltTCPHTTP alternative Port, commonly used for development or Proxy
27017MongoDBTCPMongoDB Database

TLS Positioning in OSI Model and HTTPS / HSTS

TLS (Transport Layer Security) spans L5 (Session Layer) and L6 (Presentation Layer) in the OSI model, but is classified as part of the application layer in the TCP/IP model. TLS is not an independent transport protocol, but provides encryption and identity authentication on top of TCP and below the application layer. Evolution of versions and security of each version, see Encryption Protocol Version Evolution Comparison Table.

HTTPS (HTTP over TLS): HTTP traffic is encrypted via TLS, default Port 443.

HSTS (HTTP Strict Transport Security): The server informs the browser via the HTTP header Strict-Transport-Security that subsequent requests to the domain must use HTTPS, preventing SSL Stripping attacks (where attackers downgrade HTTPS to HTTP).

HSTS DirectiveDescription
max-age=31536000Time (seconds) the browser remembers this policy, in this example, one year.
includeSubDomainsAll subdomains also forced to HTTPS.
preloadAdds the domain to the browser's built-in HSTS Preload List, eliminating the HTTP window before the first connection.

Joining HSTS Preload List

General HSTS requires the user to successfully connect once before the browser remembers "this site must use HTTPS." Before that, the first connection might still go over HTTP, leaving a window for attack. The Preload List is a list built into each browser at the factory; once a domain is listed, anyone visiting for the first time is forced to HTTPS directly.

Application process:

  1. Add Strict-Transport-Security header to HTTP response, must include preload, includeSubDomains, and max-age of at least one year.
  2. Submit domain application to hstspreload.org.
  3. Once approved, it is incorporated into the Chromium source code, and subsequently taken by Chrome, Firefox, Edge, and Safari updates.

Note: includeSubDomains is a mandatory condition; all subdomains must support HTTPS. Once joined, if you want to remove it, you must apply separately and wait for the next browser version update to take effect; confirm that the domain can maintain HTTPS long-term before applying.

SSL Stripping Attack

Attackers intercept the first HTTP request sent by the user, maintain an HTTPS connection with the server, and return a tampered HTTP page to the victim, causing credentials to be sent in plaintext. See SSL Stripping.

C# Example: HttpClient Setting TLS 1.3
csharp
using System.Net.Http;
using System.Net.Security;
using System.Security.Authentication;

// Create HttpClientHandler specifying TLS version
SocketsHttpHandler handler = new() {
    SslOptions = new() {
        // Only allow TLS 1.2 and TLS 1.3
        EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13,
    },
};

using HttpClient client = new(handler);

// Send HTTPS request
HttpResponseMessage response = await client.GetAsync("https://example.com/api/data");
response.EnsureSuccessStatusCode();

string body = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Response length: {body.Length} characters");

In practice, IHttpClientFactory should be used to manage HttpClient lifecycle to avoid Socket exhaustion issues.

DNS Security

DNSSEC (DNS Security Extensions) adds digital signatures to DNS responses, ensuring the authenticity and integrity of query results, preventing DNS Spoofing and Cache Poisoning.

Why is DNSSEC needed?

The browser receives a DNS response saying "the IP of bank.com is 1.2.3.4," how can it confirm this is not forged by an attacker?

  1. Domain signs itself: bank.com uses a private key to generate RRSIG signatures for all DNS records and publishes the corresponding DNSKEY for verification.
  2. Self-signing cannot be trusted: Anyone can generate a set of keys and sign them; having RRSIG and DNSKEY is not enough. The resolver also needs to confirm "whether this DNSKEY itself is legitimate."
  3. Parent issues credentials (DS record): The .com TLD stores a DS record in its own zone, which is the hash value of the bank.com DNSKEY. The resolver compares them and finds a match, meaning .com recognizes this key as genuine.
  4. Trace back further: Is the .com DNSKEY legitimate? The Root Zone stores the DS record for .com, and then compares it further up.
  5. Starting point of trust: The Root Zone's public key is pre-built into all operating systems and resolvers (Trust Anchor), which is the only link in the entire chain that does not require external verification.

Chain of Trust

Diagram

DNSSEC Record Types

Record TypeFull NameChineseDescription
RRSIGResource Record SignatureResource Record SignatureDigital signature of DNS record
DNSKEYDNS KeyDNS KeyStores the public key of the Zone, used to verify RRSIG
DSDelegation SignerDelegation SignerHash of the child zone public key by the parent zone, establishing a chain of trust
NSEC / NSEC3Next SecureNext Secure RecordProves a DNS record does not exist, NSEC3 additionally adds salt hash to prevent zone enumeration
Windows / Linux DNS Query Command Examples
powershell
# Windows / Linux Universal: Query basic A record and MX record
nslookup example.com
nslookup -type=MX example.com

# Windows: Query A record of specified DNS Server
Resolve-DnsName -Name example.com -Server 1.1.1.1 -Type A -DnsOnly

# Windows: View DNSKEY published by domain
Resolve-DnsName -Name example.com -Type DNSKEY -DnsOnly

# Windows: View DNSSEC signature record
Resolve-DnsName -Name example.com -Type RRSIG -DnsOnly
bash
# Linux: Basic query and concise output
dig example.com
dig example.com MX
dig example.com +short

# Linux: Query A record from specified DNS Server
dig @1.1.1.1 example.com A

# Linux: View DNSKEY published by domain
dig example.com DNSKEY

# Linux: View DS record of parent zone
dig com DS
  • Resolve-DnsName can directly specify -Server, -Type, -DnsOnly, suitable for basic DNS and DNSSEC troubleshooting on Windows systems.
  • dig @server name type is the most common basic format, e.g., dig @8.8.8.8 example.com MX means "query a certain record from the specified DNS server."
  • nslookup is suitable for basic queries; to observe DNSSEC records or more complete response fields, Resolve-DnsName and dig will be clearer.

DNSSEC vs DNS Encryption Protocols Comparison:

ProtocolPurposeDescription
DNSSECIntegrity + AuthenticityVerifies DNS response has not been tampered with, query content remains plaintext
DoH (DNS over HTTPS)Encrypt QueryEncapsulates DNS query in HTTPS, prevents query content from being eavesdropped, Port 443
DoT (DNS over TLS)Encrypt QueryEncrypts DNS query with TLS, Port 853

DNSSEC vs DoH / DoT

DNSSEC does not encrypt query content: Queries and responses remain plaintext, only ensuring the response has not been tampered with. If eavesdropping prevention is needed, DoH or DoT must be used.

VPN (Virtual Private Network) Types and Protocols Comparison Table

VPN Connection Types and Technical Principles

TypeDescriptionTypical ProtocolApplicable Scenario
Site-to-Site VPNInterconnects two fixed networks through an encrypted tunnel (e.g., Head Office ↔ Branch Office)IPsec (Tunnel Mode)Branch interconnection, cross-region data centers
Remote Access VPNIndividual users connect back to enterprise internal network from outsideSSL/TLS VPN, IPsecRemote work, business travelers accessing internal resources

Site-to-Site VPN vs Remote Access VPN Technical Principle Differences

Technical AspectSite-to-Site VPNRemote Access VPN
Connection ArchitectureGateway-to-Gateway: VPN gateway devices at both ends are responsible for establishing the encrypted tunnel, internal hosts are unawareHost-to-Gateway: User-side device directly establishes connection with enterprise VPN server
Tunnel EstablishmentPersistent Tunnel: Once configured, the tunnel exists permanently (Always-On), maintaining connection state regardless of data transmissionOn-demand: Tunnel established only when user connects, tunnel disappears after disconnection, supports multiple users connecting simultaneously but independently
Network TopologyBridge Mode: "Bridges" two different local networks into one large logical network, devices at both ends can communicate directly using internal IPsRouting Mode: User obtains virtual IP (usually assigned by VPN server's IP Pool), routing table determines which traffic goes through VPN
IP AssignmentStatic Routing: Both network segments are fixed and non-overlapping (e.g., A side uses 192.168.1.0/24, B side uses 192.168.2.0/24), routing rules pre-configuredDynamic IP Assignment: Dynamically assigns virtual IP from DHCP Pool to connected users, supports IP address reuse
Authentication MechanismDevice Authentication: Based on Pre-Shared Key (PSK), digital certificates, or identity verification of both gateways, authenticates the device rather than individual usersUser Authentication: Based on username/password, digital certificates, or Multi-Factor Authentication (MFA), each connected user requires independent authentication
Scalability ConsiderationLow Scalability: Depends on topology selection for multi-site, see table belowHigh Scalability: VPN server can serve thousands of concurrent connections, only need to increase server computing power
Failure Impact ScopeLarge Single Point Failure Impact: Gateway failure at one end completely interrupts network interconnection between the two locations, affecting all users at that locationSmall Single Point Failure Impact: Individual user connection issues do not affect others, VPN server failure can be backed up by multiple servers

Site-to-Site VPN Multi-site Topology

Hub-and-SpokeFull Mesh
ArchitectureAll branch sites only establish tunnels with the central HubEach site establishes tunnels directly with all other sites
ConnectionsN-1N×(N-1)/2
Traffic PathTraffic between branches must detour through HubEach site connects directly, no detour
Management ComplexityLow, centralized in Hub configurationHigh, number of connections grows rapidly as sites increase
LatencyHigher (one extra hop)Lower (direct connection)
Single Point FailureHub failure interrupts communication between all branches; in practice, Hub needs HA (High Availability) backupFailure of any site only affects itself, other sites can still connect directly
Applicable ScenarioMany branches, Hub bandwidth sufficientFew sites, latency-sensitive or high traffic

VPN Protocol Comparison

ProtocolOperating LayerEncryption MethodFeatures
IPsecL3 Network LayerESP (AES + HMAC)Industry standard, suitable for Site-to-Site; supports Transport / Tunnel dual modes, see IPsec Operation Mode Comparison Table.
SSL/TLS VPNL4-L7TLSCan be used via browser or lightweight Client, no need to install dedicated software; suitable for Remote Access.
WireGuardL3 Network LayerChaCha20 + Poly1305Modern lightweight protocol, extremely small code base (approx. 4000 lines), performance better than IPsec / OpenVPN.

Split Tunneling vs Full Tunneling

ModeBehaviorProsCons
Full TunnelingAll traffic goes through VPN tunnelHigh security, all traffic protected by enterprise security policyHigh bandwidth consumption, affects performance
Split TunnelingOnly enterprise resource traffic goes through VPN, rest goes through local networkSaves bandwidth, better user experienceLower security, local traffic not protected

VPN and Zero Trust

  • Full Tunneling of traditional VPN ensures all traffic is inspected, but in a Zero Trust Architecture, each resource has independent access control (PEP), weakening the role of VPN.
  • Zero Trust does not necessarily cancel VPN, but VPN is no longer the only trust boundary.

VPN Protocol Details Supplement

IPsec IKE Two-Stage Negotiation

StageNamePurposeOutput
Phase 1IKE SA EstablishmentBoth sides negotiate encryption algorithms, verify identity, establish secure management channelISAKMP SA (Internet Security Association and Key Management Protocol SA)
Phase 2IPsec SA EstablishmentWithin the secure channel of Phase 1, negotiate encryption parameters for actual data transmissionIPsec SA (a pair of unidirectional SAs, each with SPI identifier)
  • Phase 1 has two modes: Main Mode (6-step exchange, safer) and Aggressive Mode (3-step exchange, faster but identity protection weaker).
  • Phase 2 uses Quick Mode, can negotiate multiple sets of IPsec SAs.
  • IKEv2 simplified the negotiation process, merging Phase 1 + Phase 2 into 4 message exchanges (IKE_SA_INIT + IKE_AUTH).

WireGuard Technical Features

  • Based on Noise Protocol Framework, uses fixed cryptographic combinations (ChaCha20, Poly1305, Curve25519, BLAKE2s), no need to negotiate encryption algorithms.
  • Adopts Fixed Public Key Pairing: Each Peer pre-configures the other's public key, simplifying the identity verification process.
  • Uses UDP only for transmission, no TCP mode.
  • Core code is about 4,000 lines (vs OpenVPN approx. 100,000 lines), easy for security auditing.
  • Connection establishment time is usually within 100ms (IPsec / OpenVPN usually takes seconds).

SSL/TLS VPN Two Modes

ModeDescriptionApplicable Scenario
ClientlessAccess Web applications via browser, no need to install softwareTemporary access, partners, BYOD devices
Full-tunnel ClientInstall dedicated client, all traffic transmitted through TLS tunnelRemote employees needing full network access
  • Clientless mode only supports Web applications and some protocols (e.g., RDP over HTML5), functionality is limited but deployment is simplest.
  • Full-tunnel Client provides functionality equivalent to IPsec VPN, but has stronger firewall traversal capability via TLS (using TCP 443 Port).

IPsec Operation Mode Comparison Table

AspectTransport ModeTunnel Mode
Encryption ScopeEncrypts Payload only (IP header not encrypted)Encrypts entire original IP packet (including header), then wraps with new IP header
IP Header VisibilityOriginal IP header retained, real source and destination IP visibleOriginal IP header encrypted and hidden, outer header shows VPN gateway IP
Typical UseEnd-to-End (Host-to-Host) communicationGateway-to-Gateway (Site-to-Site VPN) or Remote Access VPN
SecurityLower (attacker can know communicating IPs)Higher (original IP hidden, only VPN gateway IP visible)
Packet Structure[Original IP Header][IPsec Header][Encrypted Payload][New IP Header][IPsec Header][Encrypted (Original IP Header + Payload)]
Diagram

TIP

  • AH (Authentication Header): Provides integrity verification and source authentication only, does not provide encryption.
  • ESP (Encapsulating Security Payload): Provides encryption + integrity verification + source authentication.
  • In practice, most VPNs use ESP + Tunnel Mode.
  • Transport mode is common for secure communication between two hosts within the same local network.

QUIC Protocol and HTTP/3

QUIC is a transport layer protocol developed by Google and standardized by IETF (RFC 9000), HTTP/3 uses QUIC as the underlying layer, replacing the TCP + TLS architecture of HTTP/2.

Comparison AspectHTTP/2 (TCP + TLS)HTTP/3 (QUIC)
Transport LayerTCPUDP (QUIC implements reliable transmission on UDP itself)
EncryptionTLS (layered, handshake independent)Built-in encryption (QUIC handshake merged with TLS 1.3)
Connection Establishment3-way TCP + TLS handshake (1–2 RTT)0-RTT or 1-RTT (known servers can resume connection in 0-RTT)
Head-of-Line Blocking (HOL Blocking)Exists at TCP layer (one packet loss blocks all streams)None (each stream independent, single packet loss does not affect other streams)
Connection MigrationIP change requires connection rebuildUses Connection ID, no disconnection when changing IP / network (e.g., mobile phone switching from Wi-Fi to mobile network)
Firewall/NAT TraversalTCP 443 widely allowedUDP 443, may be blocked in some environments

Security Considerations:

  • QUIC forces the use of TLS 1.3, cannot downgrade to weaker encryption versions, security is better than negotiable TLS 1.2.
  • Because it uses UDP, traditional firewalls based on TCP connection state may not be able to deeply inspect QUIC traffic, posing visibility challenges for enterprises.
  • 0-RTT data may be subject to Replay Attack, server-side needs to implement Idempotent protection for 0-RTT requests.

TIP

  • RTT (Round-Trip Time): Time from packet sent to response received. Higher RTT means higher latency. Establishing a connection requires several round trips, requiring several RTTs of waiting time.
  • TCP Three-way Handshake: TCP must complete three steps (SYN → SYN-ACK → ACK) before sending data, consuming 1 RTT. HTTPS adds TLS handshake on top, totaling 2 RTTs before data transmission can start.
  • Head-of-Line Blocking (HOL Blocking): TCP requires packets to arrive in order, one packet loss makes all subsequent packets queue for retransmission, even if other data streams are completely normal, they will be blocked.
  • Jitter (Transmission Latency Variation): Inconsistency in packet arrival time. RTT is "average round-trip latency," Jitter is "fluctuation amplitude of latency." VoIP and video conferencing are extremely sensitive to Jitter; high Jitter causes broken voice or frozen screens. Attackers can deliberately create massive Jitter through network congestion (e.g., DDoS) to reduce service quality or even trigger timeout disconnection.

NAC and 802.1X Authentication

NAC (Network Access Control) is a mechanism that performs two types of checks before a device connects to the network:

  • Identity Authentication: Confirm whether the device or user has the right to enter the network, usually implemented via 802.1X.
  • Posture Assessment: Confirm whether the endpoint security settings meet policies, including OS patches, antivirus software enabled status, whether prohibited software (e.g., P2P download tools) is installed, and whether personal firewall is enabled.

Devices that fail either check are isolated to a restricted VLAN, allowed only to access patching servers for self-patching, or directly denied connection.

NAC Architecture:

Diagram

802.1X is responsible for the "Identity Authentication" part mentioned above. It is the IEEE standard Port-based Network Access Control, using EAP (Extensible Authentication Protocol) as the identity verification framework.

802.1X Three Roles:

RoleEnglishDescriptionCommon Implementation
SupplicantSupplicantDevice or software requesting network accessWindows built-in 802.1X Client, wpa_supplicant (Linux)
AuthenticatorAuthenticatorNetwork device controlling Port switchEnterprise-grade switch, wireless AP
Authentication ServerAuthentication ServerVerifies identity and determines authorizationRADIUS server (e.g., FreeRADIUS, Microsoft NPS)

802.1X Authentication Process:

Diagram

EAP Common Method Comparison:

EAP itself is just a framework; actual authentication strength depends on the EAP method chosen. The core difference lies in "which side needs a certificate" and "whether a TLS tunnel is established."

EAP MethodServer CertificateClient CertificateAuthentication TypeFeatures
EAP-MD5Unidirectional (Server cannot be verified)Weakest; cannot prevent MITM attacks, no longer recommended
PEAPUnidirectional (Verify Server)Establishes TLS tunnel first, client authenticates with password (MSCHAPv2) inside the tunnel; most common in Windows enterprise environments
EAP-TTLSUnidirectional (Verify Server)Similar to PEAP, but supports more inner protocols (PAP, CHAP, MSCHAPv2, etc.); better cross-platform compatibility
EAP-TLSBidirectional (Mutual Authentication)Both sides need PKI certificates; highest security, but deployment cost is largest (requires managing client certificates)
EAP-FASTOptionalUnidirectional (Default)Proposed by Cisco; replaces certificates with PAC (Protected Access Credential), avoiding certificate management burden

Private IP and CIDR Subnetting

Private IP Range (RFC 1918)

Private IPs are routed only within the organization, external communication requires NAT conversion to public IPs. Public IPs are assigned by IANA/ISP and are globally unique; private IPs are managed by the organization itself and can be reused across different organizations.

Private RangeCIDRAvailable HostsCommon Scenario
10.0.0.0 – 10.255.255.25510.0.0.0/816,777,214Large enterprise internal network
172.16.0.0 – 172.31.255.255172.16.0.0/121,048,574Medium enterprise
192.168.0.0 – 192.168.255.255192.168.0.0/1665,534Home/Small office

CIDR Subnetting

In the CIDR prefix (/n), the first n bits are the network part, and the remaining (32 - n) bits are the host part.

Available hosts = 2^(32-n) - 2 (subtracting network address and broadcast address)

CIDRHost BitsAvailable HostsApplicable Scenario
/22101,022Large department (~1,000 units)
/248254General office network segment
/26662Small department
/28414Small isolated network segment
/3022Point-to-Point connection

Security Significance of Subnetting

Shrinking a subnet shrinks the Blast Radius: if one network segment is breached, the impact scope is limited to hosts within that subnet.

Practical example: Finance department 10 people → /28 (14 available IPs), even other departments in the same office building cannot directly connect.

Network Segmentation

Network segmentation cuts large networks into multiple smaller security zones, limiting lateral movement, so even if an attacker breaches one segment, they cannot directly access resources in other segments.

ImplementationEnglishLayerDescription
VLANVirtual LANL2Establishes logically isolated broadcast domains on the same physical switch. Communication between different VLANs must pass through L3 routers or firewalls.
ACLAccess Control ListL3-L4Sets rules on routers or L3 switches to filter allowed or denied traffic based on IP address, Port number, and protocol.
DMZDemilitarized ZoneL3-L7Isolated buffer zone between external network (Internet) and internal network, usually places external services (Web server, Mail server, DNS). External can access DMZ, but cannot directly enter internal network; internal can access DMZ, but DMZ hosts cannot directly move laterally to internal network after being breached.
Firewall ZoneFirewall ZoneL3-L7Divides network into zones with different trust levels (e.g., Trust / Untrust / DMZ), cross-zone traffic is checked by firewall policy.
MicrosegmentationMicrosegmentationL2-L7Sets security policies per workload (VM / Container) in virtualized or cloud environments, realizing core principles of Zero Trust architecture.

VLAN Security

VLAN (Virtual Local Area Network) cuts multiple logically independent network segments on the same physical switch, allowing traffic from different departments (e.g., Finance VLAN 10, Engineering VLAN 20) not to interfere with each other, even if they share the same physical line. The implementation standard is 802.1Q, which adds a 4-byte VLAN Tag to the Ethernet frame, allowing the switch to determine which network segment each packet belongs to.

Port Types

Frames sent by terminal devices (computers) do not carry VLAN tags themselves, but the switch must know which VLAN the frame belongs to when forwarding. The Port type determines how the switch handles this tag at each connection point.

TypeConnection ObjectDescription
Access PortTerminal device (computer, printer, IP Phone)Belongs to a single VLAN. Terminal devices send Untagged Ethernet frames; the switch adds the 802.1Q Tag of the VLAN the Port belongs to when receiving (Ingress); strips the Tag when forwarding out (Egress). The terminal device itself is unaware of the VLAN.
Trunk PortBetween switches, switch to routerCarries traffic for multiple VLANs simultaneously. Frames are transmitted in Tagged 802.1Q format, the Tag remains unchanged throughout the Trunk link, and the receiving device must be able to interpret the VLAN Tag and forward it to the corresponding VLAN accordingly.
Native VLANVLAN to which untagged frames on a Trunk Port belong, defaults to VLAN 1, mainly used for compatibility with older devices that do not support 802.1Q. Attackers can use this mechanism to launch Double Tagging attacks (see next section), Native VLAN should be changed to an unused non-VLAN 1 ID.
Scenario Comparison

Access Port — Door to Department Office

Employees (terminal devices) do not need to wear any identification stickers inside the office because everyone in the office is from the same department. When an employee walks out of the department door, the guard at the door (Access Port) will stick a department identification sticker (VLAN Tag) on their back; it will be torn off when they enter. The terminal device does not need to know the existence of the sticker at all; sticking and tearing are handled entirely by the switch.

Trunk Port — Shared Elevator in the Building

People from the Finance department and Engineering department share the same elevator (Trunk Port). To let the guard on another floor identify which department everyone belongs to, everyone must stick on a department sticker (Tagged) before entering the elevator, and the sticker is kept throughout the elevator ride without being torn off. Upon arrival, the guard at the receiving end (another switch) sees the sticker and knows which department to guide the person to.

Native VLAN — People without stickers

If someone walks into the elevator without any stickers (Untagged frame arrives at Trunk Port), the building has a default rule: everyone is classified as "default identity" (Native VLAN, defaults to VLAN 1). Attackers can use this rule to add two layers of tags to the frame, the outer layer matches the Native VLAN, the switch strips the outer layer, and the inner tag sends the traffic into an unauthorized VLAN (i.e., Double Tagging attack).

Frame Transmission Process

Diagram

VLAN Hopping Attack

Attackers exploit VLAN configuration flaws to cross VLAN boundaries and access unauthorized network segments.

Double Tagging

Vulnerability Principle: Exploits the default behavior of switches "automatically stripping tags" when processing Native VLANs, smuggling malicious packets into unauthorized network segments. This is a one-way (One-way) blind attack.

Trigger Conditions:

  1. Environment Topology: There must be 2 or more switches on the attack path, connected via Trunk Port.
  2. Attacker Location: The Port where the attacker is located must belong to a VLAN that matches the Trunk's Native VLAN (usually defaults to VLAN 1).

Malicious Payload Structure:

The attacker self-forges a special frame with two 802.1Q tags: [Outer Tag: Native VLAN (e.g., VLAN 1)] + [Inner Tag: Target Segment (e.g., VLAN 10)] + [Malicious Data].

Attack Execution Lifecycle (Execution Pipeline):

  1. Switch 1 (Vulnerability Trigger Point): Receives the attacker's packet, prepares to send it into the Trunk channel. Upon discovering "Outer Tag = Native VLAN," triggers the system default rule: strip the outer tag.
  2. Trunk (Smuggling Channel): The outer tag is torn off, the hidden [Inner Tag: VLAN 10] is exposed, and it is transmitted in this state in the Trunk.
  3. Switch 2 (Victim Forwarding Node): Receives the packet from the Trunk. Switch 2 only sees [Inner Tag: VLAN 10], and according to normal logic, forwards it to the target host in VLAN 10 without any defense.
Diagram

This attack is naturally one-way: the target host's response frame follows the normal VLAN 10 path and cannot return to the attacker, so it is mostly used to trigger target behavior (e.g., ARP poisoning, service probing), rather than two-way data theft.

Switch Spoofing (Fake Trunk)

Most switches have DTP (Dynamic Trunking Protocol) enabled by default on Ports, which automatically negotiates whether to establish a Trunk connection with the other side. The attacker host sends DTP negotiation messages, inducing the switch to promote the Port to a Trunk Port. Once negotiation succeeds, the attacker host starts receiving tagged frames for all VLANs, and VLAN isolation completely fails.

Defense MeasureDefense ObjectDescription
Modify Native VLANDouble TaggingChange Native VLAN to an unused non-VLAN 1 ID, making it impossible for the attacker to match the outer tag
Disable DTPSwitch SpoofingExplicitly set Port to Access mode and disable auto-negotiation, prohibiting unauthorized devices from negotiating Trunk
Disable Unused PortsBothSet idle Ports to shutdown and assign to an isolated VLAN, reducing attack surface

SDN Security (Software Defined Networking)

In traditional networks, each switch and router contains its own Control Plane (decision logic) and Data Plane (packet forwarding). If security rules need to be updated, they must be configured on each device individually, and any missed device creates a gap. SDN decouples the control plane from the device and centralizes it to the SDN Controller, with devices only responsible for executing forwarding instructions.

Three-Layer Architecture

Diagram
ComponentDescription
Application LayerNetwork applications (e.g., load balancing, firewall policy), pass policies to the controller via Northbound API (usually REST API).
Control LayerSDN Controller (e.g., OpenDaylight, ONOS), calculates global forwarding rules after receiving application layer instructions, then issues them to devices.
Infrastructure LayerPhysical switch/router, receives controller instructions via Southbound API (e.g., OpenFlow), does not make routing decisions itself.
Scenario Comparison

Traditional networking is like having a guard room on every floor of a building, where each guard has their own manual of entry rules and judges whether to let people in. Updating rules requires running to every guard room, and missing one creates a loophole.

The SDN approach is to establish a central control room (SDN Controller) and abolish the rule manuals in each guard room. Guards no longer judge for themselves; they report to the control room when they encounter anyone, and the control room decides whether to let them in or intercept them, then transmits the instructions back to the guard to execute.

  • Northbound API: Management personnel (application layer) issue policies to the control room via the internal communication system (REST API), e.g., "block this IP."
  • Southbound API: The control room issues specific instructions to guards on each floor via a dedicated channel (OpenFlow).

Security Advantages:

  • Centralized Security Policy: Define security rules uniformly on the controller and deploy them to all devices at once, avoiding inconsistencies caused by individual configuration.
  • Dynamic Response: When abnormal traffic is detected, the controller can modify global forwarding rules in real-time to isolate infected hosts without individual operation.
  • Network Visibility: The controller masters the global traffic state, facilitating anomaly detection and forensic analysis.

Security Risks:

  • Controller is a Single Point of Failure: Once the controller is breached, the forwarding rules of the entire network are controlled. Requires deploying HA (High Availability) clusters and strictly restricting the controller's access permissions.
  • Northbound API Attack: If an attacker gains application layer access, they can issue malicious instructions to the controller via REST API (e.g., open all traffic, bypass firewall rules). Requires implementing API authentication and authorization.
  • Southbound API Attack: If an attacker can insert forged OpenFlow messages, they can directly manipulate the switch's forwarding rules. Communication between the controller and devices must be forced to use TLS encryption.

IPv6 Security Considerations

IPv4 uses 32-bit addresses (approx. 4.3 billion), which have long been exhausted. IPv6 expands the address to 128 bits (approx. 3.4×10³⁸), which is the long-term replacement solution. Due to the massive IPv4 infrastructure, most networks are currently in a Dual Stack transition period, running IPv4 and IPv6 simultaneously. This parallel state brings new security considerations: if security policies are designed only for IPv4, IPv6 traffic becomes a blind spot.

IPsec is a mandatory support (but not mandatory to enable) in the IPv6 specification, providing native end-to-end encryption capability, which is an inherent security advantage that IPv4 does not have.

Security RiskDescription
Dual Stack RiskWhen IPv4 and IPv6 are enabled simultaneously, if IPv6 lacks corresponding security policies (firewall rules, IDS intrusion detection system signatures), attackers can bypass protections targeting only IPv4.
RA ForgeryIPv6 uses SLAAC for automatic address assignment, a process dependent on RA messages sent by routers. Attackers can send forged RA messages, setting themselves as the default gateway, an effect similar to IPv4's ARP Spoofing.
IPv6 Tunnel AbuseTransition mechanisms like Teredo, 6to4 encapsulate IPv6 packets in IPv4 for transmission, potentially bypassing firewalls and IDS that do not support IPv6.
Address Reconnaissance DifficultyAn IPv6 /64 subnet contains 2⁶⁴ addresses, traditional IP-by-IP scanning is infeasible. Attackers switch to DNS queries, multicast addresses, or EUI-64 (rules for deriving IPv6 addresses from device MAC addresses) for reconnaissance.
Defense MeasureDescription
Block Unused IPv6 TrafficIf the organization has not deployed IPv6, explicitly block IPv6 traffic on the firewall, including Ports used by Teredo, 6to4 tunnels, to avoid becoming a security blind spot.
Dual Stack Policy SynchronizationIf dual stack is deployed, firewall rules, IDS/IPS signatures, and log records must cover both IPv4 and IPv6 simultaneously, not just protect one end.
Enable RA GuardEnable RA Guard on switches to allow only legitimate routers to send RA messages, blocking forged Router Advertisements.

💡 Terminology Quick Check

  • SLAAC: Stateless Address Autoconfiguration — IPv6 devices do not need a DHCP server, automatically generating their own IP addresses via RA messages.
  • RA: Router Advertisement — Messages periodically broadcast by routers, informing devices in the network segment of gateway addresses and network prefixes.
  • EUI-64: Extended Unique Identifier (64-bit) — Converts a device's 48-bit MAC address into a 64-bit interface identifier, used to automatically generate the host part of an IPv6 address.
  • Teredo / 6to4: IPv6 over IPv4 tunneling transition mechanisms — Encapsulates IPv6 packets in IPv4 for transmission, allowing pure IPv4 environments to connect to IPv6 networks.
  • RA Guard: Router Advertisement Guard — Switch feature, allows only designated legitimate router Ports to send RA messages, preventing forged Router Advertisements.
  • Dual Stack: Dual Stack — The same device enables both IPv4 and IPv6 simultaneously, currently the most common transition deployment method.

Wireless Network Encryption Comparison Table

The WPA (Wi-Fi Protected Access) series is a Wi-Fi Alliance certification standard for wireless network security, starting from the structural vulnerabilities of WEP (Wired Equivalent Privacy), evolving through WPA → WPA2 → WPA3 to strengthen encryption and authentication mechanisms.

StandardEncryption AlgorithmAuthentication MethodKey LengthKnown VulnerabilitiesCurrent Recommendation
WEPRC4Open/Shared Key40/104 bitIV repetition attack, keys can be cracked in minutesDisable
WPATKIP (RC4 improved)PSK / 802.1X128 bitTKIP has Michael attack, designed as a transition scheme for WEPNot recommended
WPA2AES-CCMPPSK / 802.1X128 bitKRACK attack (Key Reinstallation Attack), can force reuse of NonceStill usable, but should upgrade to WPA3
WPA3AES-GCMP / AES-CCMPSAE / 802.1X128/192 bitDragonblood attack (patched)Recommended

Known Vulnerability Description

  • IV Repetition Attack (WEP): WEP uses a 24-bit Initialization Vector (IV) paired with RC4 for stream encryption. The IV space is only 2²⁴ ≈ 16 million types, which is exhausted quickly in busy networks and starts repeating. When two packets use the same IV, ciphertext XOR can cancel out the key stream, thereby restoring plaintext or reversing the key.
  • Michael Attack (WPA/TKIP): TKIP (Temporal Key Integrity Protocol) is the encryption protocol for WPA, designed to strengthen WEP vulnerabilities without replacing old hardware. It still uses RC4 at the bottom, but adds per-packet keys (to avoid IV repetition) and the message integrity code Michael (to prevent forgery). Michael's design strength is insufficient; attackers can forge packets and pass verification in a short time; TKIP was an emergency transition scheme, and its overall design has inherent limitations, eventually replaced by WPA2's AES-CCMP.
  • KRACK (WPA2): Key Reinstallation Attack. Attackers replay message 3 of the four-way handshake, forcing the client to reinstall the key and reset the Nonce to 0. After the Nonce repeats, the AES-CCMP encryption protection fails, and attackers can decrypt packets or forge data. See the four-way handshake explanation below.
  • Dragonblood (WPA3/SAE): Side-channel attack targeting early implementations of SAE, inferring passwords by measuring timing differences or cache access behavior during the Dragonfly calculation process. The Wi-Fi Alliance patched this in WPA3 Revision 1, and current correct implementations are not affected.

WPA2 4-Way Handshake

The four-way handshake confirms during connection that both sides hold the same PMK (Pairwise Master Key, derived from the passphrase), and negotiates the PTK (Pairwise Transient Key) for encrypting unicast data and the GTK (Group Temporal Key) for broadcast. The PMK itself is not transmitted over the network, both sides calculate it from the passphrase.

Diagram
KRACK Attack Process

The attacker disguises as a man-in-the-middle, intercepts message 4 (ACK), causing the AP to mistakenly believe the client did not receive message 3, and the AP retransmits message 3 according to the protocol. Each time the client receives message 3, it reinstalls the key and resets the Nonce to 0. After the Nonce repeats, the same key encrypts different packets, and the attacker can restore the key stream, thereby decrypting or forging packets.

Diagram

WPA3 and SAE

WPA2 vs WPA3 Core Differences:

AspectWPA2WPA3
Key Exchange4-Way Handshake (PSK)SAE (Dragonfly protocol)
Offline Dictionary AttackFeasible (offline brute force after capturing handshake packets)Infeasible (each handshake requires interaction, cannot be brute-forced offline)
Forward Secrecy (PFS)Not supportedSupported (SAE generates independent session keys each time)
Open NetworkNo encryptionOWE (Opportunistic Wireless Encryption)
Enterprise SecurityWPA2-EnterpriseWPA3-Enterprise (192-bit CNSA suite)

SAE (Simultaneous Authentication of Equals)

SAE is based on the Dragonfly key exchange protocol (RFC 7664). The core idea of Dragonfly is to map the password to a point on an elliptic curve (PWE, Password Element), and perform key exchange based on this; the password itself is never transmitted over the network, nor does it leave any material for offline comparison. Attackers must initiate a complete handshake interaction with the other side for each guess, unlike WPA2 where they can capture packets once and brute-force the password offline infinitely.

SAE handshake is divided into two stages:

  • Commit Stage: Both sides map the password and MAC address to a PWE (Password Element) on the elliptic curve, generate a random private value, calculate scalar and element, and exchange them. Even if the attacker captures these public values, they cannot verify password guesses without interacting with the other side.
  • Confirm Stage: Both sides calculate confirmation codes with the shared key and verify each other, ensuring both sides know the correct password, completing bidirectional identity authentication.
Diagram

OWE (Opportunistic Wireless Encryption)

OWE is used for open networks without passwords (e.g., coffee shop Wi-Fi). Traditional open networks have no encryption at all, and anyone on the same network can eavesdrop on traffic. OWE lets each client and AP perform an ECDH key exchange during connection, establishing an independent encrypted channel for that connection, preventing passive eavesdropping.

OWE does not verify the AP's identity (open networks have no password to bind the AP), so it cannot prevent Evil Twin Attacks, only providing eavesdropping protection, not identity authentication.

WPA3 Version Description:

VersionApplicable ScenarioCore Features
WPA3-PersonalHome / Small OfficeSAE replaces PSK, provides PFS
WPA3-EnterpriseGovernment / High-security environmentsSupports 192-bit security suite (CNSA, Commercial National Security Algorithm)
OWEPublic Wi-Fi (Open Network)Establishes independent encrypted channel for each user, no password required

Purdue Model (OT / ICS Layered Security Architecture)

The Purdue Model (Purdue Enterprise Reference Architecture, PERA) is an industrial control system (ICS / OT) security layered reference architecture, dividing the OT environment into six levels (Level 0–5) according to function, explicitly specifying the equipment, functions, and security isolation requirements for each level.

LevelNameEquipment / FunctionDescription
Level 0Field DevicesSensor, Actuator, MotorBottom-level hardware directly controlling physical processes
Level 1ControlPLC (Programmable Logic Controller), RTU (Remote Terminal Unit), DCSReceives sensor signals, controls actuators according to logic
Level 2SupervisorySCADA (Supervisory Control and Data Acquisition), HMI (Human Machine Interface)Operator interface, monitors and controls Level 1 equipment; security incidents often spread from this level
Level 3Manufacturing OperationsMES (Manufacturing Execution System), Historian data collection serverScheduling, production tracking, recording manufacturing data
Level 3.5 (iDMZ)Industrial DMZProxy, Jump Server, Data Diode, FirewallBuffer isolation zone between OT (Level 3) and IT (Level 4); Ensures there is never a direct network connection between IT and OT, all data exchange must pass through proxy servers or jump servers in the iDMZ, effectively preventing IT-layer malware from directly entering the OT core.
Level 4–5Enterprise and External NetworkERP, Business Systems, InternetTraditional IT environment

OT Security Key Principles

  • The boundary between Level 1 (PLC/RTU) and Level 2 (SCADA/HMI) is the lateral movement path most often exploited by attackers: after breaching SCADA (Level 2), they can issue commands downward, directly affecting physical processes at Level 1 (e.g., Ukraine power grid attack incident).
  • iDMZ (Industrial DMZ): Corresponds to Level 3.5, is the necessary buffer isolation zone between OT and IT; data should be transmitted unidirectionally through proxy servers or Data Diodes in the iDMZ to prevent IT-side threats from entering the OT network in reverse.
  • Purdue vs Zero Trust: Zero Trust requires verifying identity for every request, but many PLC devices in OT environments lack authentication capabilities, so Zero Trust in OT environments is primarily implemented in network boundary control between Level 3–4.

💡 Terminology Quick Check

  • IT: Information Technology — Computer systems dealing with data, communication, and business logic, e.g., servers, databases, ERP. The core difference from OT is that IT prioritizes Confidentiality, while OT prioritizes Availability.
  • OT: Operational Technology — Hardware and software systems that directly control physical equipment and industrial processes.
  • ICS: Industrial Control System — Upper-level collective term for OT, covering control systems like PLC, SCADA.
  • PLC: Programmable Logic Controller — Industrial computer that receives sensor signals and controls actuators according to set logic.
  • RTU: Remote Terminal Unit — Data acquisition and control equipment deployed on-site, communicating with SCADA.
  • DCS: Distributed Control System — Industrial control architecture that distributes control functions to multiple nodes, commonly used in large manufacturing plants.
  • SCADA: Supervisory Control and Data Acquisition — System that centrally monitors multiple on-site devices, operators monitor and control via HMI interface.
  • HMI: Human Machine Interface — Graphical interface for operators to interact with industrial control systems.
  • MES: Manufacturing Execution System — Information system managing production scheduling and tracking manufacturing progress.
  • ERP: Enterprise Resource Planning — Management system integrating enterprise resources such as finance, HR, supply chain, belongs to IT side.
  • Data Diode: Hardware device that allows data to flow in only one direction, commonly used at the OT / IT boundary to prevent external threats from entering the OT network in reverse.

Linux / Windows Network Security Tool Comparison Table

Firewall Configuration

FunctionWindowsLinux
Built-in FirewallWindows Defender Firewalliptables / nftables / firewalld
CLI Managementnetsh advfirewall / PowerShell New-NetFirewallRuleiptables / nft / firewall-cmd
GUI Managementwf.msc (Windows Firewall with Advanced Security)Cockpit Web Console / UFW (Uncomplicated Firewall)
Rule PersistenceAutomatically savediptables requires iptables-save / iptables-restore; firewalld uses XML configuration files for persistence

Linux Firewall Evolution

  • iptables: Classic packet filtering tool for Linux 2.4+, based on the Netfilter framework. Rules organized by Chain and Table.
  • nftables: Introduced in Linux 3.13+, successor to iptables. Syntax is more unified, performance is better, and it has gradually replaced iptables.
  • firewalld: Default dynamic firewall management tool for RHEL / CentOS / Fedora. Bottom layer can use iptables or nftables. Supports Zone concept and real-time rule changes.
iptables / nftables Firewall Rule Examples

iptables Common Rules

bash
# Allow established connections and related traffic
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

# Allow SSH (Port 22)
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# Allow HTTPS (Port 443)
iptables -A INPUT -p tcp --dport 443 -j ACCEPT

# Default deny all inbound traffic
iptables -P INPUT DROP

# Save rules (Debian/Ubuntu)
iptables-save > /etc/iptables/rules.v4

nftables Equivalent Rules

bash
# Create table and chain
nft add table inet filter
nft add chain inet filter input { type filter hook input priority 0 \; policy drop \; }

# Allow established connections
nft add rule inet filter input ct state established,related accept

# Allow SSH and HTTPS
nft add rule inet filter input tcp dport { 22, 443 } accept

# Save rules
nft list ruleset > /etc/nftables.conf

Network Diagnostic Tools

FunctionWindowsLinuxDescription
IP Config Queryipconfig / ipconfig /allip addr / ifconfig (deprecated)View IP, subnet mask, gateway of network interface cards.
Connection Statusnetstat -anss -tulnp / netstat -tulnpView current TCP/UDP connections and listening Ports. ss is the modern replacement for netstat.
Route Tracingtracerttraceroute / mtrTrace the hop path of packets to the destination. mtr combines ping and traceroute.
DNS Querynslookup / Resolve-DnsNamedig / nslookupGeneral query uses nslookup; for DNSSEC records, see DNS Security section for centralized examples.
ARP Table Queryarp -aip neigh / arp -aView local ARP cache.
Common Network Diagnostic Command Examples
bash
# Trace route (find where packets are dropped or latency spikes)
tracert 8.8.8.8                     # Windows
traceroute 8.8.8.8                  # Linux

# View listening Ports (confirm which services are exposed externally)
netstat -ano | findstr LISTENING    # Windows
ss -tulnp                           # Linux (-t TCP, -u UDP, -l listening, -n no name resolution, -p show process)

0.0.0.0 / 127.0.0.1 / localhost Easily Confused Security Traps

AddressSemanticsSecurity Risk
127.0.0.1Loopback address, packets do not leave the hostService limited to local access, cannot connect from outside.
localhostHostname, defaults to 127.0.0.1 (IPv6 environment is ::1)/etc/hosts can be tampered with to point to other addresses; in dual-stack environments, if firewall rules only block 127.0.0.1, ::1 might be missed.
0.0.0.0Server binding context: listen on all network interfaces, including external interfacesMisusing 0.0.0.0 during development exposes services intended only for local access directly to the public network.

Common traps:

  • Database (Redis, MySQL) in development environment bound to 0.0.0.0 and deployed directly, lacking external firewall protection, exposed directly to the public network.
  • 127.0.0.1 inside a container is limited to the container itself, host cannot access; if host access is needed, must explicitly bind to 0.0.0.0 or host IP, and pair with firewall to restrict source IP.

Network Sniffing and Packet Capture

ToolPlatformDescription
WiresharkWindows / Linux / macOSGUI packet analysis tool, supports parsing hundreds of protocols.
tcpdumpLinux / macOSCLI packet capture tool, lightweight and efficient, suitable for server environments.
tsharkWindows / Linux / macOSCLI version of Wireshark, suitable for script automation.
tcpdump Common Commands
bash
# Capture all traffic on eth0 interface
tcpdump -i eth0

# Capture HTTPS traffic only (Port 443)
tcpdump -i eth0 port 443

# Capture traffic for a specific host
tcpdump -i eth0 host 192.168.1.100

# Capture TCP SYN packets (first step of three-way handshake)
tcpdump -i eth0 'tcp[tcpflags] & tcp-syn != 0'

# Save capture results to pcap file (for Wireshark analysis)
tcpdump -i eth0 -w capture.pcap -c 1000

# Read pcap file
tcpdump -r capture.pcap

# Exclude SSH traffic (avoid capturing own remote connection)
tcpdump -i eth0 not port 22
Wireshark Display Filter Common Syntax
text
# Filter by protocol
http
dns
tls
tcp
arp

# Filter by IP address
ip.addr == 192.168.1.100
ip.src == 10.0.0.1
ip.dst == 172.16.0.0/12

# Filter by Port
tcp.port == 443
tcp.dstport == 80

# Filter by HTTP method
http.request.method == "POST"

# Filter by DNS query name
dns.qry.name == "example.com"

# Filter by TLS version
tls.handshake.version == 0x0304  # TLS 1.3

# Filter by TCP Flag
tcp.flags.syn == 1 && tcp.flags.ack == 0  # SYN (new connection)
tcp.flags.reset == 1                       # RST (connection reset)

# Combine conditions
ip.addr == 192.168.1.0/24 && tcp.port == 443 && tls
  • Display Filter: Filter display among captured packets, syntax as above.
  • Capture Filter: Filter during capture, syntax is BPF (Berkeley Packet Filter), same as tcpdump (e.g., host 192.168.1.100 and port 443).

Cryptography

Cryptography and Data Protection Technology Comparison Table

Technology CategoryKey CountOperation SpeedCore PurposeCommon Algorithms
Symmetric Encryption1 (Encryption and decryption share the same key)Extremely fastBulk data, files, full disk encryptionAES, DES, RC4
Asymmetric Encryption2 (Public key encrypts/Private key decrypts; Private key signs/Public key verifies)Extremely slowKey exchange (sending symmetric keys), digital signatures, identity authenticationRSA, ECC (Elliptic Curve)
Hash FunctionNone (One-way conversion, cannot be restored)FastPassword storage (with Salt), data integrity verificationSHA-2 (e.g., SHA-256, SHA-512), MD5 (deprecated)

Symmetric vs Asymmetric Encryption/Decryption Process Comparison

Diagram

Symmetric Encryption Block Modes (ECB / CBC / CTR / GCM)

Symmetric encryption processes data block by block in fixed sizes, and the "mode" determines how blocks are chained and operated; the security gap between different modes is significant.

ModeFull NameParallelizableSecurityFeature Description
ECBElectronic CodebookIdentical plaintext blocks produce identical ciphertext, leaking data patterns (e.g., image contours still visible after encryption)
CBCCipher Block Chaining⚠️Previous ciphertext block used as XOR input for next block, eliminates ECB pattern leakage; but cannot be parallelized, and has POODLE (Padding Oracle On Downgraded Legacy Encryption) padding vulnerability
CTRCounter ModeConverts block encryption to stream encryption, can be parallelized, good performance
GCMGalois/Counter Mode✅ RecommendedCTR encryption + GMAC (Galois Message Authentication Code) integrity verification, belongs to AEAD (Authenticated Encryption with Associated Data) mode; TLS 1.2+ mainstream choice (AES-GCM)

Why ECB Mode is Insecure

ECB mode encrypts each block independently, and identical plaintext blocks always produce identical ciphertext blocks. This leaks data patterns: encrypting a Linux penguin (Tux) image with ECB mode still clearly reveals the penguin's outline; after switching to CBC / GCM, it becomes complete noise. ECB mode should not be used in any scenario.

ECB Mode Encryption Penguin Image Visual Comparison

Nonce and IV (Initialization Vector)

ConceptFull NameDescription
IVInitialization VectorIn modes like CBC, CFB, XORed with the first plaintext block before encryption, ensuring identical plaintext produces different ciphertext in different encryption operations
NonceNumber Used OnceIn modes like CTR, GCM, used as the initial value for the counter, must never be reused (under the same key)

Core requirements for IV/Nonce differ by mode:

ModeRoleCore RequirementRecommended Length
ECBNone
CBCIVUnpredictable: Must be truly random; when IV is predictable, attackers can launch chosen-plaintext attacks (BEAST attack exploits this vulnerability to crack TLS Cookie)16 bytes
CTRNonceUnique: Must not repeat under the same key, not mandatorily random; distributed systems are difficult to maintain global counters, practical recommendation is still to use random numbers12 bytes
GCMNonce (Specification calls it IV, refers to the same value)Same as CTR; 12 bytes (96-bit) can directly form the initial counter block J0, best performance, is the official recommended length12 bytes

Nonce/IV does not need to be secret, can be transmitted publicly with ciphertext

The key (Key) must never leak, but Nonce/IV is a public value, its role is just to make identical plaintext produce different encryption results each time. The receiver gets Nonce + Key to decrypt, standard practice is to transmit Nonce and ciphertext together.

Transmission MethodPracticeApplicable Scenario
Concatenated before ciphertext (Most common)[Nonce (12 bytes)][Ciphertext], decryption end cuts the first 12 bytes to get NonceAPI transmission, file encryption
Independent database fieldStored in database table as EncryptedData and CryptoNonce fields, SELECT together during decryptionDatabase field encryption
HTTP Header / JWTPlaced in X-Nonce Header or JWT PayloadAPI communication

Why GCM prefers 12-byte Nonce

  • GCM's underlying block size is 128-bit. When IV/Nonce is exactly 96-bit (12 bytes), the specification can directly form J0 = IV || 0^31 || 1, which is the complete 128-bit initial block after padding a 32-bit counter tail.
  • Subsequent counter increments only need to operate on the right 32-bit counter segment, so this is GCM's most natural and efficient practice.
  • If IV is not 96-bit, GCM must first map IV to J0 via GHASH, adding an extra operation, making implementation more complex and performance usually worse.
  • The true core risk remains reusing Nonce under the same key. Non-12 bytes does not mean it is definitely insecure, but 96-bit is the conventional choice for best interoperability and performance.

Disaster of Nonce Reuse

CTR / GCM encryption is essentially stream encryption ( is XOR, bitwise comparison, same is 0, different is 1):

KS = KeyStream(Key, Nonce)    ← Determined entirely by Key and Nonce
Ciphertext = Plaintext ⊕ KS

As long as Key and Nonce are the same, KS is exactly the same. If an attacker can obtain two pieces of ciphertext encrypted with the same key and same Nonce:

C1 = P1 ⊕ KS
C2 = P2 ⊕ KS

C1 ⊕ C2 = P1 ⊕ P2    ← KS cancels out, key disappears

Specific Restoration Process

Suppose the attacker captures two ciphertexts simultaneously (e.g., after KRACK forces Nonce reset, both packets use Nonce = 0 for encryption):

PlaintextHexadecimalDescription
P1"GET "47 45 54 20HTTP request start (including trailing space, total 4 bytes), fixed format, attacker knows
P2PASS50 41 53 53Target plaintext, attacker wants to know
KSA3 F2 1C 8BKey stream, attacker does not know

Ciphertext seen by attacker after encryption:

C1 = 47⊕A3  45⊕F2  54⊕1C  20⊕8B  =  E4 B7 48 AB
C2 = 50⊕A3  41⊕F2  53⊕1C  53⊕8B  =  F3 B3 4F D8

Attacker calculates C1 ⊕ C2, KS cancels out:

E4⊕F3  B7⊕B3  48⊕4F  AB⊕D8  =  17 04 07 73  =  P1 ⊕ P2

Restore P2 using known P1 ("GET "):

17⊕47  04⊕45  07⊕54  73⊕20  =  50 41 53 53  =  "PASS"

The attacker never obtained the key, yet completely restored P2.

GCM is even worse: When Nonce repeats, not only is plaintext leaked, but the attacker can also calculate the GMAC authentication key H, after which they can forge arbitrary packets and pass integrity verification, both encryption and authentication fail. WPA2's KRACK attack exploits this principle.

C# Example: AES-GCM Encryption/Decryption
csharp
using System.Security.Cryptography;
using System.Text;

// --- Encryption ---
byte[] key = RandomNumberGenerator.GetBytes(32); // 256-bit key
byte[] nonce = RandomNumberGenerator.GetBytes(AesGcm.NonceByteSizes.MaxSize); // 12 bytes
byte[] plaintext = Encoding.UTF8.GetBytes("Confidential Data: Account, Password, and PII");
byte[] ciphertext = new byte[plaintext.Length];
byte[] tag = new byte[AesGcm.TagByteSizes.MaxSize]; // 16 bytes
byte[] associatedData = Encoding.UTF8.GetBytes("metadata-v1"); // Additional Authenticated Data (not encrypted but integrity verified)

using (AesGcm aesGcm = new(key, AesGcm.TagByteSizes.MaxSize)) {
    aesGcm.Encrypt(nonce, plaintext, ciphertext, tag, associatedData);
}

Console.WriteLine($"Nonce:      {Convert.ToBase64String(nonce)}");
Console.WriteLine($"Ciphertext: {Convert.ToBase64String(ciphertext)}");
Console.WriteLine($"Tag:        {Convert.ToBase64String(tag)}");

// --- Decryption ---
byte[] decrypted = new byte[ciphertext.Length];

using (AesGcm aesGcm = new(key, AesGcm.TagByteSizes.MaxSize)) {
    aesGcm.Decrypt(nonce, ciphertext, tag, decrypted, associatedData);
}

Console.WriteLine($"Decrypted:  {Encoding.UTF8.GetString(decrypted)}");

Asymmetric Encryption Algorithms

Asymmetric encryption uses a pair of matching public/private keys to handle two types of tasks: "encryption/decryption" and "signature/verification," with RSA and ECC being the mainstream algorithms, established on different mathematical hard problems.

AspectRSAECC (Elliptic Curve Cryptography)
Mathematical FoundationDifficulty of large number factorizationECDLP (Elliptic Curve Discrete Logarithm Problem)
Key Length for Equivalent Security2048-bit or 3072-bit256-bit (≈ RSA 3072-bit)
Operation SpeedSlower (slower as key gets longer)Faster (short keys achieve equivalent security)
Key and Signature SizeLarger (occupies more bandwidth and storage)Smaller, suitable for bandwidth or storage-constrained environments
Applicable ScenarioTraditional PKI (Public Key Infrastructure), systems needing backward compatibilityIoT (Internet of Things) devices, mobile devices, TLS 1.3
Main AlgorithmEncryption: RSA-OAEP (Optimal Asymmetric Encryption Padding)
Signature: RSA-PSS (Probabilistic Signature Scheme)
Signature: ECDSA (Elliptic Curve Digital Signature Algorithm)
Key Exchange: ECDH (Elliptic Curve Diffie-Hellman) / ECDHE (Ephemeral version)

TIP

  • ECC has obvious advantages, why is RSA still mainstream?: Existing PKI infrastructure, Hardware Security Modules (HSM), and most legacy compliance standards are built around RSA; ECC is the default choice for new systems (TLS 1.3 forces ECDHE), but the legacy system base is massive, making full replacement difficult in the short term.
  • TLS 1.3 forces the use of ECDHE for key exchange, no longer supporting RSA static key exchange.
  • Quantum Computer Threat: Both RSA and ECC could be cracked by Shor's Algorithm, Post-Quantum Cryptography (PQC) is currently being standardized (NIST announced the first batch of PQC standards in 2024).
  • Security strength equivalence: ECC 256-bit ≈ RSA 3072-bit ≈ Symmetric Encryption 128-bit.
C# Example: RSA Encryption/Decryption and Digital Signature
csharp
using System.Security.Cryptography;
using System.Text;

// --- Generate RSA Key Pair ---
using RSA rsa = RSA.Create(2048);
byte[] publicKey = rsa.ExportRSAPublicKey();
byte[] privateKey = rsa.ExportRSAPrivateKey();

// === Encryption/Decryption (Public key encrypts → Private key decrypts) ===
byte[] plaintext = Encoding.UTF8.GetBytes("Confidential Data");

using RSA rsaEncryptor = RSA.Create();
rsaEncryptor.ImportRSAPublicKey(publicKey, out _);
byte[] encrypted = rsaEncryptor.Encrypt(plaintext, RSAEncryptionPadding.OaepSHA256);
Console.WriteLine($"Encrypted: {Convert.ToBase64String(encrypted)}");

using RSA rsaDecryptor = RSA.Create();
rsaDecryptor.ImportRSAPrivateKey(privateKey, out _);
byte[] decrypted = rsaDecryptor.Decrypt(encrypted, RSAEncryptionPadding.OaepSHA256);
Console.WriteLine($"Decrypted: {Encoding.UTF8.GetString(decrypted)}");

// === Digital Signature (Private key signs → Public key verifies) ===
byte[] document = Encoding.UTF8.GetBytes("Contract Content v1.0");

using RSA rsaSigner = RSA.Create();
rsaSigner.ImportRSAPrivateKey(privateKey, out _);
byte[] signature = rsaSigner.SignData(
    document,
    HashAlgorithmName.SHA256,
    RSASignaturePadding.Pss
);
Console.WriteLine($"Signature: {Convert.ToBase64String(signature)}");

using RSA rsaVerifier = RSA.Create();
rsaVerifier.ImportRSAPublicKey(publicKey, out _);
bool isValid = rsaVerifier.VerifyData(
    document,
    signature,
    HashAlgorithmName.SHA256,
    RSASignaturePadding.Pss
);
Console.WriteLine($"Signature verification result: {isValid}");
C# Example: ECDSA Digital Signature
csharp
using System.Security.Cryptography;
using System.Text;

// --- Generate ECDSA Key Pair (P-256 curve) ---
using ECDsa ecdsa = ECDsa.Create(ECCurve.NamedCurves.nistP256);
byte[] publicKey = ecdsa.ExportSubjectPublicKeyInfo();
byte[] privateKey = ecdsa.ExportPkcs8PrivateKey();

// --- Signature ---
byte[] document = Encoding.UTF8.GetBytes("Transaction Record #20250101-001");
byte[] signature = ecdsa.SignData(document, HashAlgorithmName.SHA256);
Console.WriteLine($"Signature: {Convert.ToBase64String(signature)}");

// --- Verification (Simulate receiver only has public key) ---
using ECDsa verifier = ECDsa.Create();
verifier.ImportSubjectPublicKeyInfo(publicKey, out _);
bool isValid = verifier.VerifyData(document, signature, HashAlgorithmName.SHA256);
Console.WriteLine($"ECDSA signature verification result: {isValid}");

// --- Key Size Comparison ---
Console.WriteLine($"ECDSA P-256 Public Key Size: {publicKey.Length} bytes");
Console.WriteLine($"ECDSA P-256 Signature Size: {signature.Length} bytes");
Application Layer Cryptography Practice (Extra protection beyond TLS)

TLS, if implemented correctly (forced TLS 1.2+, valid certificate), already provides sufficient transport encryption. The following practices are applicable to scenarios with compliance requirements or defense-in-depth needs.

Recommended Process: Backend generates time-limited asymmetric key pair

  1. When the frontend enters the login page, call the backend API to obtain a temporary public key.
  2. The backend generates an RSA key pair, stores the private key temporarily, sets a TTL (Time To Live), and only returns the public key.
  3. The frontend encrypts the password with the public key and sends it.
  4. The backend decrypts with the corresponding private key, verifies the login, and destroys the private key immediately after decryption.

Private Key Temporary Storage Scheme:

SchemeApplicable ConditionsNote
Redis (Recommended)Multiple instances or Redis environmentTTL automatically expires, supports horizontal scaling
Application MemorySingle instance, no RedisKey lost after application restart, cannot be shared across instances
DatabaseNone of the aboveRequires manual cleanup of expired keys, not the first choice

Key Validity: Recommended 5–15 minutes, and designed for single use (invalidated immediately after successful decryption), preventing Replay Attack.

Key Expiration Handling: Frontend re-fetches

When the backend returns an error that the key does not exist or has expired, the frontend calls the API again to obtain a new public key and retries. It is not recommended to retain an overlap period for the previous key: login is a one-time short operation, the overlap period increases implementation complexity without almost any benefit to user experience, and having two valid private keys simultaneously expands the exposure window.

Why use asymmetric instead of symmetric?

Symmetric encryption requires sharing a key between frontend and backend. Static keys written in frontend source code are equivalent to plaintext; if dynamically issued by the backend, the delivery process itself faces the same protection problem (chicken-and-egg). The public key of asymmetric encryption can be public, even if intercepted, it can only encrypt and cannot decrypt, and the private key always remains on the backend.

Why fetch public key via API instead of static public key file?

Static public keys need to be replaced via deployment. In a frontend-backend separation architecture, it also requires coordinating frontend deployment timing (if the frontend is maintained by different teams or vendors, rotation costs are higher), leading to longer rotation cycles and larger exposure windows when keys leak. The API method can enforce validity periods and single-use, and keys can be rotated without deployment.

Hash Function

Hash functions convert input of arbitrary length into a fixed-length output (digest), possessing four core characteristics:

  • One-wayness: Cannot reverse-engineer the original input from the output.
  • Determinism: Identical input always produces identical output.
  • Avalanche Effect: Changing one bit of input produces a completely different output.
  • Collision Resistance: Difficult to find two different inputs that produce the same output (collision).

Main uses: Data integrity verification, digital signatures (signing the digest rather than the original text, reason see Digital Signature section), password storage.

Fast Hash Algorithms

Fast hashes are designed for speed, suitable for integrity verification and digital signatures. The mainstream algorithms are the SHA family:

  • MD5 / SHA-1: Actual collision attack cases have been discovered, should no longer be used in security scenarios (digital signatures, certificate issuance). If only detecting accidental data corruption (not malicious tampering), MD5 is technically still usable, but new systems should avoid it.
  • SHA-2 (SHA-256, SHA-384, SHA-512): Current mainstream standard, widely used in TLS, digital signatures, certificates. The suffix number is the output bit count (SHA-256 outputs 256 bits fixed, SHA-512 outputs 512 bits fixed), regardless of input size.
  • SHA-3: Another design architecture (based on Keccak sponge function, unrelated to SHA-2), serves as an alternative standard, less common.

Hash Collision: Two different inputs produce the same hash output. Collision itself does not allow attackers to reverse-engineer passwords, but it allows attackers to forge fake documents with the same hash value as the original, which is fatal to digital signature security.

C# Example: SHA-256 Hash Verification (Integrity Verification)
csharp
using System.Security.Cryptography;
using System.Text;

byte[] hash = SHA256.HashData(Encoding.UTF8.GetBytes("Important Document Content"));
Console.WriteLine(Convert.ToHexStringLower(hash));

// Verify integrity: Compare hash values of two pieces of data
byte[] hash2 = SHA256.HashData(Encoding.UTF8.GetBytes("Important Document Content"));
Console.WriteLine($"Integrity consistent: {CryptographicOperations.FixedTimeEquals(hash, hash2)}");

Salt and Pepper Comparison:

MechanismStorage LocationIs each data different?Description
SaltDatabase (same table as hash)✅ Each is differentA set of random salt values for each user, prevents Rainbow Table Attack
PepperEnvironment Variable / Secrets Manager (not in database)❌ Globally sharedGlobal secret value, even if the entire database leaks, cannot restore password without pepper

Can be used simultaneously: hash(password + Salt + Pepper). Salt stored in database, Pepper stored outside system settings.

Origin of Salt and Pepper Names

These two terms originate from cooking metaphors: "Add ingredients to the password, making it harder for attackers to taste the original flavor."

  • Salt: First proposed by Robert Morris and Ken Thompson in the Unix password system in the 1970s. Mixing random values into passwords before hashing makes identical passwords produce different hash values, rendering rainbow tables (pre-calculated hash comparison tables) ineffective.
  • Pepper: An extended concept, corresponding to "another seasoning." Unlike salt placed on the table (database), pepper is hidden in the kitchen safe (environment variable), so even if the table is flipped, it cannot be found.

Slow Hash Algorithms (Key Stretching)

Key Stretching increases computational cost deliberately, making brute force infeasible. The following is a comparison of mainstream slow hash algorithms:

AlgorithmCore MechanismAdjustable ParametersMemory RequirementAnti-GPU/ASICNote
PBKDF2Repeated execution of HMAC (e.g., HMAC-SHA256)Iteration countLow.NET built-in (Rfc2898DeriveBytes); NIST recommended; OWASP suggests at least 600,000 iterations (SHA-256)
bcryptBased on Blowfish block encryptionCost FactorMedium (4 KB)⚠️Mature design, widely used; input limited to 72 bytes
scryptPBKDF2 + massive memory accessN (CPU/memory cost), r, pHigh (adjustable)Memory-intensive design resists ASIC; parameter tuning is complex
Argon2Memory-intensive + optional multi-threadingMemory, iterations, parallelismHigh (adjustable)2015 PHC (Password Hashing Competition) winner; divided into Argon2d (anti-GPU), Argon2i (anti-side-channel), Argon2id (hybrid, recommended)

Selection Recommendation

Slow hash's core threat is "offline GPU brute force." GPU has thousands of computing cores, relying solely on iteration counts to slow down CPU has limited effect, memory hardening (Memory-Hard) is the key. If each calculation requires massive memory (e.g., 64MB), GPU's VRAM becomes the bottleneck (16GB VRAM ÷ 64MB = max 256 concurrent instances).

Selection Priority:

  1. Argon2id (First choice): Memory, iterations, and parallelism dimensions are all adjustable; combines the advantages of Argon2d (anti-GPU/ASIC) and Argon2i (anti-side-channel). OWASP suggests minimum parameters: 64MB memory, 3 iterations, 4 parallelism.
  2. bcrypt (Second choice): Mature and reliable, widely supported; memory requirement is only 4KB, but has a 72-byte input length limit.
  3. scrypt: Memory requirement higher than bcrypt, but the three parameters (N / r / p) are complex to tune, less commonly used in practice.
  4. PBKDF2 (Restricted scenarios): No memory hardening; only selected under FIPS compliance or .NET built-in API limitations.

All algorithms must be paired with random Salt to prevent rainbow table attacks.

Why NIST recommends PBKDF2, and .NET has no built-in Argon2 / bcrypt

Reason for NIST recommending PBKDF2

NIST's cryptographic standards are premised on FIPS 140 compliance. PBKDF2 uses HMAC-SHA256 or HMAC-SHA512 at the bottom, both of which are NIST-defined standards, fully compliant with the FIPS whitelist. bcrypt uses Blowfish block encryption at the bottom (not a FIPS-approved algorithm); Argon2 uses Blake2b (not included in FIPS core cryptographic modules).

PBKDF2 lacks memory hardening, NIST's corresponding approach is to require significantly increased iteration counts. OWASP suggests at least 600,000 iterations (HMAC-SHA256) to compensate for the lack of memory hardness, which still provides sufficient security mathematically while maintaining FIPS compliance.

Why .NET BCL has no built-in Argon2 / bcrypt

Three reasons:

  1. Limitations of OS Native APIs: .NET's cryptographic classes (System.Security.Cryptography) prioritize calling OS underlying APIs (CNG on Windows, OpenSSL on Linux) rather than implementing them themselves. Windows CNG has long not provided native support for Argon2 or bcrypt, so .NET has no official encapsulation.
  2. Historical Compatibility of ASP.NET Core Identity: The Identity framework was built on PBKDF2 (Rfc2898DeriveBytes) from the beginning. If the default algorithm is changed, password hashes in existing databases will not be verifiable. Microsoft chose to increase iteration counts generation by generation (.NET 8 default is already hundreds of thousands), rather than directly replacing the algorithm.
  3. Design Philosophy of Lean Core: Modern .NET's strategy is to keep the core lightweight, leaving specific domains to open-source packages. Argon2 and bcrypt already have mature NuGet packages (e.g., Konscious.Security.Cryptography.Argon2, BCrypt.Net-Next), no need for official mandatory inclusion.

PBKDF2 Underlying Structure

PBKDF2 code requires passing HashAlgorithmName.SHA256, which looks like processing a fast hash, but this is PBKDF2's unique design: it is essentially executing HMAC-SHA256 repeatedly for a specified number of times (600,000 iterations), "slow" is piled up by the count, not because the underlying algorithm itself is slow.

The underlying layers of bcrypt, scrypt, and Argon2 are not directly repeated fast hashes. bcrypt uses Blowfish block encryption; scrypt adds a memory mixing function outside of PBKDF2; Argon2 uses Blake2b as the calculation unit for memory filling. This is also the fundamental reason why PBKDF2 is easier to parallelize on GPU than the other three, as GPUs are inherently good at executing massive parallel SHA operations.

C# Example: PBKDF2 Password Hashing and Verification
csharp
using System.Security.Cryptography;

// --- Generate Hash (at registration) ---
string password = "MySecureP@ssw0rd";
byte[] salt = RandomNumberGenerator.GetBytes(16);
int iterations = 600_000;
HashAlgorithmName hashAlgorithm = HashAlgorithmName.SHA256;
int keySize = 32; // 256 bits

byte[] hash = Rfc2898DeriveBytes.Pbkdf2(
    password,
    salt,
    iterations,
    hashAlgorithm,
    keySize
);

// Store in database: Base64(salt) + Base64(hash) + iterations
string saltBase64 = Convert.ToBase64String(salt);
string hashBase64 = Convert.ToBase64String(hash);
Console.WriteLine($"Salt: {saltBase64}");
Console.WriteLine($"Hash: {hashBase64}");

// --- Verify Password (at login) ---
string inputPassword = "MySecureP@ssw0rd";
byte[] storedSalt = Convert.FromBase64String(saltBase64);
byte[] storedHash = Convert.FromBase64String(hashBase64);

byte[] inputHash = Rfc2898DeriveBytes.Pbkdf2(
    inputPassword,
    storedSalt,
    iterations,
    hashAlgorithm,
    keySize
);

bool isValid = CryptographicOperations.FixedTimeEquals(inputHash, storedHash);
Console.WriteLine($"Password verification result: {isValid}");

Fast Hash vs Slow Hash: Applicable Scenarios

The only use for slow hash is: Password Storage. For other scenarios, a 100ms+ computational cost is a performance burden, not a security guarantee.

Fast HashSlow Hash
Calculation TimeNanosecond level100ms+
Password Storage❌ Easily brute-forced
Integrity / Verification / HMAC❌ Performance infeasible

Take JWT as an example: HS256 uses HMAC-SHA256 (fast hash) to sign Header.Payload, and each API request needs to recalculate the verification once. If bcrypt is used, each verification takes 100ms, the server can verify at most dozens of Tokens per second, completely unable to serve.

Therefore, JWT should use fast hash because the security threat models of JWT and passwords are different:

  • Password: After an attacker steals the hash from the database, they can perform offline infinite brute force enumeration; the slower the speed, the harder the attack.
  • JWT HMAC: Must hold the Secret key to generate a valid signature; without the key, even knowing it uses SHA-256 cannot forge it, security relies on key secrecy, not hash speed.

Message Authentication Code (MAC)

A simple Hash can only confirm "whether the message has been tampered with," but cannot confirm "who sent it." Because anyone can easily calculate the hash value, if an attacker intercepts and tampers with the message and then attaches a new hash value, the receiver has no way to distinguish the truth.

MAC introduces a "shared secret key between both parties" on the basis of hash, simultaneously achieving two core security goals:

  • Data Integrity: Proves the message has not been tampered with during transmission.
  • Source Authentication (Identity Authentication): Proves the message indeed comes from an authorized party holding the same key.

Operation Process:

  1. Sender: Inputs "message" and "key" together to generate a fixed-length Verification Tag, and sends it along with the message.
  2. Receiver: After receiving the message, uses their own same key to recalculate the tag once.
  3. Verification: If the calculated tag matches the received one, it means "the message is complete and the source is legitimate"; if they do not match, the message is directly rejected.

HMAC (Hash-based MAC)

HMAC is currently the most prevalent MAC implementation, relying on conventional hash functions (e.g., SHA-256) at the bottom.

Why not just Hash(Key ‖ Message)? The most intuitive idea is to concatenate the key directly in front of the message and then hash it. But this structure (Keyed-Hash) has a serious security vulnerability: even if an attacker does not know the key, they can intercept the packet and "append" malicious content to the end of the original message, and then use mathematical properties to deduce a new valid hash value (this technique is called Length Extension Attack).

To solve this problem, HMAC adopts a Nested Hash design architecture:

  • Inner Operation: Key XORed with the fixed constant ipad (0x36 × block length) defined in RFC 2104, concatenated with the message, hashed for the first time to get the inner digest.
  • Outer Operation: Key XORed with another fixed constant opad (0x5C × block length), concatenated with the inner digest, hashed for the second time to get the final tag.

The two constants are different, making the key derivation values of the inner and outer layers completely unrelated; the outer hash truncates the internal state of SHA-256, and the attacker cannot continue to extend from the final output, fundamentally immunizing against length extension attacks. Both XOR and the two-layer hash are completed inside the HMAC implementation library, the caller only needs to pass in K and M.

Formula: HMAC(K, M) = H((K ⊕ opad) ‖ H((K ⊕ ipad) ‖ M))

Symbol Description

  • : Concatenation, equivalent to A + B, concatenates two pieces of data head-to-tail into one.
  • : XOR (Exclusive OR), equivalent to A ^ B, compares two pieces of data of equal length bit by bit, same is 0, different is 1.

Case: Integrity Protection of API Transfer Requests

Suppose an API protects transfer requests with a shared key, compare the differences between two MAC implementations in a length extension attack.

text
Shared Key: K = "s3cr3tKey"
Original Message: M = "amount=100&to=alice"

Scheme A — SHA256(K ‖ M) direct concatenation:

text
Sender calculates:
  Tag = SHA256("s3cr3tKey" ‖ "amount=100&to=alice")

Attacker intercepts packet, obtains (M, Tag)
SHA-256 uses Merkle–Damgård structure: final output = internal state after digesting all blocks
→ Holding Tag is equivalent to holding "internal state after digesting K ‖ M", can continue to calculate

  Append extra = "&override=9999&to=bob"
  NewTag = SHA256_continue(Tag, extra)
         ≡ SHA256("s3cr3tKey" ‖ "amount=100&to=alice" ‖ [padding] ‖ extra)
                                                                          ↑ No need to know K at all

Receiver verifies: SHA256(K ‖ Tampered Message) == NewTag  ← Matches perfectly, verification passes, attack successful

What is [padding]

After SHA-256 finishes processing the input data, it automatically performs Merkle–Damgård padding at the end to meet the 512-bit block operation requirement. Padding rules:

  1. Mark end: Append a 1 bit at the end of the message.
  2. Pad with zeros: Continue to append 0 bits until the last 64 bits of the entire block remain.
  3. Record length: Write the total length of the original input in the last 64 bits.
[ Original Input K ‖ M ] [ 1 ] [ 00...pad zeros...00 ] [ Original Length (64 bits) ]
|<---------------- Exactly a multiple of 512 bits ---------------->|

The padding content is uniquely determined by the original input length, and the attacker only needs to know the length of K ‖ M to accurately deduce it, which is the fundamental reason why length extension attacks are feasible.

Scheme B — HMAC:

text
Sender calculates:
  inner = SHA256((K ⊕ ipad) ‖ M)       ← Fixed 256-bit inner digest
  Tag   = SHA256((K ⊕ opad) ‖ inner)   ← Outer layer wrapped again

Attacker similarly obtains (M, Tag), attempts to append extra, extending from Tag:

  Attacker expansion:
    SHA256((K ⊕ opad) ‖ SHA256((K ⊕ ipad) ‖ M) ‖ [padding] ‖ extra)
                               └───────────────────┘
                               inner_old (contains only M), extra is in outer layer

  True HMAC(K, M ‖ extra) expansion:
    SHA256((K ⊕ opad) ‖ SHA256((K ⊕ ipad) ‖ M ‖ extra))
                               └──────────────────────┘
                               inner_new (M ‖ extra enter inner layer together)

  inner_old ≠ inner_new → Outer layer input different → Verification must fail, attack invalid

Not all integrity requirements need HMAC

The premise of HMAC is that both parties already share a secret key, introducing the burden of key management (distribution, rotation, revocation). If the scenario only requires "confirming whether the data has been tampered with" and does not need to confirm "who sent it," use a hash function directly:

RequirementSuitable MethodReason
Only need to confirm data integrity, both parties trust each otherHash (SHA-256)No key required, anyone can verify, no management burden
Need to confirm message comes from a party holding the keyHMACKey gives verification identity meaning
Need non-repudiation (verifiable by third party)Digital SignaturePublic/private key separation, private key holder cannot deny

Common "hash only" scenarios: file integrity verification (SHA-256 checksum), Git commit hash, data deduplication (Content-based Deduplication).

CMAC (Cipher-based MAC)

CMAC does not rely on hash functions, but instead uses Symmetric Block Encryption (e.g., AES) at the bottom to generate verification tags, standardized by NIST SP 800-38B.

Applicable Scenario: In environments already equipped with hardware AES acceleration chips (e.g., HSM hardware security modules, IoT embedded devices, smart cards), using CMAC can share the underlying AES calculation unit, saving hardware resources, and is highly compliant with FIPS's strict compliance requirements.

MAC vs Digital Signature

MAC (HMAC)Digital Signature
Key TypeSymmetric (both share the same one)Asymmetric (private key signs, public key verifies)
Non-repudiation❌ (both can generate, cannot distinguish)✅ (only private key holder can sign)
Verification MethodRequires shared keyVerify with public key, no prior sharing required
SpeedFastSlow
Typical UseTLS record layer integrity, JWT HS256, API request signatureCertificates, code signing, contract signing
C# Example: HMAC-SHA256 Calculation and Verification
csharp
using System.Security.Cryptography;
using System.Text;

// --- Generate HMAC ---
byte[] key = RandomNumberGenerator.GetBytes(32); // 256-bit key
byte[] message = Encoding.UTF8.GetBytes("Transaction Amount: 50000, Payee Account: 1234-5678");

byte[] hmac = HMACSHA256.HashData(key, message);
Console.WriteLine($"HMAC-SHA256: {Convert.ToBase64String(hmac)}");

// --- Verify HMAC (receiver holds the same key) ---
byte[] receivedMessage = Encoding.UTF8.GetBytes("Transaction Amount: 50000, Payee Account: 1234-5678");
byte[] computedHmac = HMACSHA256.HashData(key, receivedMessage);

bool isValid = CryptographicOperations.FixedTimeEquals(hmac, computedHmac);
Console.WriteLine($"HMAC verification result: {isValid}");

// --- Tamper Detection ---
byte[] tamperedMessage = Encoding.UTF8.GetBytes("Transaction Amount: 99999, Payee Account: 1234-5678");
byte[] tamperedHmac = HMACSHA256.HashData(key, tamperedMessage);

bool isTampered = CryptographicOperations.FixedTimeEquals(hmac, tamperedHmac);
Console.WriteLine($"Tampered message verification result: {isTampered}"); // False

Digital Signature and General Encryption: Public/Private Key Usage Comparison

The two uses of asymmetric encryption, the usage direction of public/private keys is exactly opposite:

General Encryption (Sending Confidential Data)

StepActionKey Used
1Sender encrypts plaintextReceiver's Public Key
2Receiver decryptsReceiver's Private Key

Purpose: Confidentiality (only the receiver holding the private key can read)

Digital Signature (Verify Source and Integrity)

StepActionKey Used
1Sender performs fast hash on plaintext (e.g., SHA-256) → Message Digest
2Sender encrypts digest with private key → Digital SignatureSender's Private Key
3Transmit "Plaintext + Digital Signature"
4Receiver decrypts signature with public key → Obtain Digest ASender's Public Key
5Receiver performs same fast hash on plaintext (e.g., SHA-256) → Obtain Digest B
6Compare Digest A and B → Match means verification passed

Purpose: Integrity + Non-repudiation (plaintext is transmitted in plaintext, confidentiality is not guaranteed)

Diagram

TIP

  • Digital Signature ≠ Encryption: In the signature process, the plaintext is transmitted in plaintext, only guaranteeing "who sent it" and "whether it has been tampered with."
  • If both confidentiality + signature are needed: Sign first, then encrypt the whole with the receiver's public key (or symmetric key).
  • Why perform fast hash before signing? Asymmetric encryption is extremely slow, signing an entire document directly is impractical; the digest after fast hash is fixed length (e.g., SHA-256 = 256 bits), signature speed is much faster. Here, slow hash is not used because signature requires integrity and efficiency, not resistance to offline brute force.

Digital Envelope

Digital Envelope combines the advantages of symmetric and asymmetric encryption, is the most common hybrid encryption method in practice:

  1. Sender generates a one-time symmetric key (Session Key), uses it to encrypt data (fast speed).
  2. Uses the receiver's public key to encrypt the symmetric key (only encrypts the short key, asymmetric encryption can afford it).
  3. Transmits the encrypted data and the encrypted symmetric key together.
  4. Receiver uses their own private key to decrypt the symmetric key, then uses the symmetric key to decrypt the data.

Difference from digital signature:

MechanismProtection GoalKey Used
Digital EnvelopeConfidentiality (only receiver can read)Receiver's public key encrypts, receiver's private key decrypts
Digital SignatureIntegrity + Non-repudiation (confirm source)Sender's private key signs, sender's public key verifies

Key exchange in TLS handshake is essentially an application of digital envelope.

Diagram

Selection timing for symmetric vs asymmetric vs hybrid encryption

ScenarioRecommended SchemeReason
Bulk data encryption (disk, file, database)Symmetric Encryption (AES-GCM)Fast speed, suitable for bulk data
Key exchange, digital signatureAsymmetric Encryption (RSA / ECC)Solves key distribution problem, provides identity verification
Network transmission (TLS, email encryption)Hybrid Encryption (Digital Envelope)Combines advantages of both: asymmetric key exchange + symmetric data encryption
Password storageKey Stretching (Argon2id / bcrypt)One-way hash, no decryption needed
Data integrity verificationHMAC / Digital SignatureHMAC suitable for shared keys; signature suitable for public verification

PKI (Public Key Infrastructure) Trust Chain

ComponentEnglishDescription
Root CARoot CATop of the trust chain, self-signed certificate, built into browser/OS trust list
Intermediate CAIntermediate CAIssued by Root CA, signs end-entity certificates on behalf, reduces risk of Root CA private key exposure
Registration Authority (RA)Registration AuthorityCA's identity verification front-end, responsible for verifying applicant identity (e.g., domain ownership, organizational documents), notifies CA to issue certificate after approval; CA itself does not directly contact applicants
End-Entity CertificateEnd-Entity CertificateCertificate used by websites or services, issued by Intermediate CA
Certificate Revocation List (CRL)Certificate Revocation ListPeriodically published list of revoked certificates, client must actively download and check
Online Certificate Status Protocol (OCSP)Online Certificate Status ProtocolReal-time query of revocation status of a single certificate, more real-time than CRL

TIP

  • Trust chain verification process: Browser receives server certificate → Check issuer (Intermediate CA) → Trace back to Root CA → Confirm Root CA is in trust list.
  • OCSP Stapling: Server queries its own certificate status from CA on behalf, attaches result to TLS handshake and transmits to client, avoiding client directly connecting to CA (reduces latency and privacy risk).
Diagram
C# Example: X.509 Certificate Loading and Verification
csharp
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;

// --- Load PFX certificate (with private key) ---
string pfxPath = "server.pfx";
string pfxPassword = "P@ssw0rd";
using X509Certificate2 cert = new(pfxPath, pfxPassword, X509KeyStorageFlags.EphemeralKeySet);

Console.WriteLine($"Subject:    {cert.Subject}");
Console.WriteLine($"Issuer:     {cert.Issuer}");
Console.WriteLine($"Not Before: {cert.NotBefore:yyyy-MM-dd}");
Console.WriteLine($"Not After:  {cert.NotAfter:yyyy-MM-dd}");
Console.WriteLine($"Thumbprint: {cert.Thumbprint}");
Console.WriteLine($"Algorithm:  {cert.SignatureAlgorithm.FriendlyName}");
Console.WriteLine($"Has PK:     {cert.HasPrivateKey}");

// --- Verify Certificate Chain ---
using X509Chain chain = new();
chain.ChainPolicy.RevocationMode = X509RevocationMode.Online;
chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain;
chain.ChainPolicy.VerificationFlags = X509VerificationFlags.NoFlag;

bool isChainValid = chain.Build(cert);
Console.WriteLine($"<br />Certificate chain verification result: {isChainValid}");

foreach (X509ChainElement element in chain.ChainElements) {
    Console.WriteLine($"  [{element.Certificate.Subject}]");
    foreach (X509ChainStatus status in element.ChainElementStatus) {
        Console.WriteLine($"    Status: {status.StatusInformation}");
    }
}

// --- RSA Signature with Certificate ---
using RSA? rsaPrivateKey = cert.GetRSAPrivateKey();
if (rsaPrivateKey is not null) {
    byte[] data = Encoding.UTF8.GetBytes("Data to sign");
    byte[] signature = rsaPrivateKey.SignData(
        data,
        HashAlgorithmName.SHA256,
        RSASignaturePadding.Pss
    );
    Console.WriteLine($"<br />RSA Signature: {Convert.ToBase64String(signature)}");

    using RSA? rsaPublicKey = cert.GetRSAPublicKey();
    bool verified = rsaPublicKey!.VerifyData(
        data,
        signature,
        HashAlgorithmName.SHA256,
        RSASignaturePadding.Pss
    );
    Console.WriteLine($"Signature verification: {verified}");
}

HSM (Hardware Security Module)

HSM is a physical device specifically designed to protect cryptographic keys, providing a tamper-resistant security environment:

AspectDescription
Core FunctionKey generation, storage, and usage are all completed inside the hardware, private keys never leave the HSM
Tamper-Resistant DesignAutomatically destroys keys when physically disassembled (Zeroization)
Compliance StandardFIPS 140-2 / FIPS 140-3 (US Federal Standard), divided into Level 1–4
Common UseRoot CA key protection, bank transaction signature, TLS private key protection, code signing
Cloud FormAWS CloudHSM, Azure Dedicated HSM, GCP Cloud HSM

TIP

  • Difference between HSM and software key management (e.g., Azure Key Vault, AWS KMS): HSM guarantees keys are calculated within a FIPS-verified hardware boundary, software solutions' keys may briefly appear in memory.
  • Enterprise PKI root CA private keys are usually stored in offline HSMs (not connected to the internet), enabled only when issuing Intermediate CA certificates.

Key Archiving and Escrow

MechanismEnglishDescriptionRisk
Key ArchivingKey ArchivingOrganization keeps copies of encryption keys itself to decrypt historical data in the future (e.g., reading files encrypted by an employee after they leave)Archival storage itself becomes an attack target
Key EscrowKey EscrowKey copies are kept by a trusted third party (e.g., government agency or notary), can be retrieved under specific conditions (e.g., court order)Third party breached or abuses power, causing large-scale key leakage
  • Key archiving is usually only applicable to encryption keys, signature keys should not be archived (otherwise others can impersonate signatures).
  • Archived keys must be stored with high-strength encryption and access permissions strictly restricted (e.g., multi-party holding decryption).

TLS (Transport Layer Security)

Version Evolution Comparison Table (SSL → TLS)

VersionRelease YearCurrent StatusMajor Changes and Milestones
SSL 2.01995Deprecated (RFC 6176)Initial public version, serious design flaws: MAC uses MD5, a fast hash, handshake lacks integrity protection, cannot prevent replay attacks.
SSL 3.01996Deprecated (RFC 7568)Significantly corrected SSL 2.0, but still has POODLE (Padding Oracle On Downgraded Legacy Encryption) attack, exploiting CBC (Cipher Block Chaining) padding flaws, overall design cannot be patched.
TLS 1.01999Deprecated (RFC 8996)Redefined based on SSL 3.0, introduced HMAC (Hash-based Message Authentication Code) to replace MAC, but fixed IV (Initialization Vector) makes BEAST (Browser Exploit Against SSL/TLS) attack feasible.
TLS 1.12006Deprecated (RFC 8996)Added explicit IV to fix BEAST vulnerability, limited improvements, primarily a transition version.
TLS 1.22008Widely deployed, still validIntroduced AEAD (Authenticated Encryption with Associated Data) encryption mode (AES-GCM); replaced MD5/SHA-1 with fast hashes like SHA-256; supports ECDHE (Elliptic Curve Diffie-Hellman Ephemeral) to achieve PFS (Perfect Forward Secrecy).
TLS 1.32018Current StandardRemoved all weak algorithms (RSA static key exchange, RC4, DES, 3DES); forced PFS; handshake reduced from 2-RTT to 1-RTT; supports 0-RTT fast reconnection.

TLS Version Evolution

  • SSL 2.0 / 3.0: Fundamental design flaws, deprecated entirely, should not be used in any scenario.
  • TLS 1.0 / 1.1: Extension patch of SSL, limited progress, fully deprecated by mainstream browsers in 2021.
  • TLS 1.2: Modern HTTPS foundational milestone, introduced AEAD + SHA-256 + ECDHE, currently widely deployed. The SHA-256 here is for fast hash purposes, used for handshake integrity and cryptographic operations like HMAC / PRF.
  • TLS 1.3: Cleared all room for "backward compatibility" compromises, forced PFS, faster handshake.

TLS 1.2 Handshake Process (ECDHE Key Exchange)

The purpose of TLS handshake is to securely establish symmetric encryption keys over an insecure network. The following is the complete process of TLS 1.2 using ECDHE key exchange:

StepDirectionActionTransmission StatePurpose
1Client → ServerClient HelloPlaintextInform supported Cipher Suite, TLS version, Client Random
2Server → ClientServer HelloPlaintextSelected cipher suite, return Server Random
3Server → ClientCertificatePlaintextPresent X.509 certificate (containing server public key) for client to verify identity
4Server → ClientServer Key ExchangePlaintext (with signature)Send ECDHE ephemeral public key, signed with server's long-term private key to ensure parameters not tampered with
5Client → ServerClient Key ExchangePlaintextSend client's ECDHE ephemeral public key
6Both sidesCalculate Pre-Master SecretNot transmittedBoth sides use the other's ECDHE public key + own ECDHE private key, independently calculate the same value
7Both sidesDerive Session KeyNot transmittedDerive symmetric encryption key using Client Random + Server Random + Pre-Master Secret
8Both sidesChange Cipher SpecPlaintextInform the other side: subsequent messages use symmetric encryption
9Both sidesFinishedEncryptedFirst encrypted message, verifies integrity of the entire handshake process; verification basis belongs to fast hash family cryptographic operations
10Both sidesApplication Data TransmissionSymmetric EncryptionAll subsequent data transmitted using Session Key encryption
Diagram

TIP

  • Why not use asymmetric encryption directly for data? Asymmetric encryption is extremely slow (hundreds to thousands of times slower than symmetric), only used in the handshake phase to negotiate symmetric keys.
  • E (Ephemeral) in ECDHE stands for "temporary key": a new key pair is generated for each connection, even if the server's long-term private key leaks later, past communications cannot be decrypted, which is PFS (Perfect Forward Secrecy).
  • Signature in Step 4 uses the server's long-term private key (corresponding to the public key in the certificate), not the ECDHE ephemeral private key. Before signing, it also performs fast hash on parameters, the purpose is to let the client confirm "these ECDHE parameters indeed come from the real server."
  • TLS 1.3 Simplification: Removed Change Cipher Spec, handshake reduced from 2-RTT to 1-RTT; supports 0-RTT fast reconnection (but has replay attack risk).

TLS 1.3 Improvements

AspectTLS 1.2TLS 1.3
Key ExchangeSupports RSA static key exchange (no PFS)Only allows ECDHE / DHE (forced PFS)
Handshake Latency2-RTT1-RTT (supports 0-RTT fast reconnection)
Cipher SuiteSupports CBC, RC4, etc. old modesOnly allows AEAD (AES-GCM, ChaCha20-Poly1305)
Hash AlgorithmSupports MD5, SHA-1Only allows fast hashes SHA-256 and above
Handshake EncryptionMost of handshake is plaintextHandshake messages encrypted after Server Hello
0-RTTNot supportedSupported (has replay attack risk, use with caution)

Practical recommendation: New systems should default to TLS 1.3; if backward compatibility for old clients is needed, allow TLS 1.2 but must disable RSA key exchange and CBC mode.

Perfect Forward Secrecy (PFS)

PFS ensures that past encrypted communications remain secure even if the server's long-term private key leaks:

Key Exchange MethodPFSDescription
RSA Static Key ExchangeClient encrypts Pre-Master Secret with server public key; after server private key leaks, all historical traffic can be decrypted
DHE / ECDHE (Ephemeral Key)Each connection generates a new ephemeral key pair; ephemeral private key destroyed after connection ends, even if long-term private key leaks, it cannot be retrospectively decrypted

TLS 1.3 forces the use of ECDHE, guaranteeing all connections have PFS at the protocol level.

Diffie-Hellman Key Exchange and MITM Attack Risk

Diffie-Hellman (DH) allows both sides to negotiate a shared key over an insecure channel, but the original DH protocol does not provide identity authentication, making it vulnerable to Man-in-the-Middle (MitM) attacks:

Diagram

Countermeasure: In TLS, DH/ECDHE parameters must be paired with the server's digital signature (first perform fast hash on parameters, then sign with long-term private key), allowing the client to verify that the parameters indeed come from a legitimate server. This is the role of TLS handshake step 4 (Server Key Exchange + Signature).

Cryptographic Attack Techniques

Attack TypeEnglishDescriptionTarget
Birthday AttackBirthday AttackExploits birthday paradox, finds hash collision in approx 2^(n/2) attempts (n is hash bit count). E.g., 128-bit hash only needs approx 2^64 attemptsHash functions (MD5, SHA-1)
Length Extension AttackLength Extension AttackFor hash functions with Merkle–Damgård structure (MD5, SHA-1, SHA-2), after attacker holds output of H(secret ‖ message), they can calculate new valid hash after appending extra content without knowing secret. Commonly used to attack MACs implemented as "key directly concatenated before message then hashed"Hash functions; MACs implemented as H(key ‖ message)
Known Plaintext AttackKnown Plaintext AttackAttacker possesses partial "plaintext + corresponding ciphertext" pairs, deduces key or decrypts other ciphertextsSymmetric encryption
Chosen Plaintext AttackChosen Plaintext AttackAttacker can choose arbitrary plaintext and obtain its ciphertext (e.g., access to encryption Oracle), deducing keySymmetric/Asymmetric encryption
Chosen Ciphertext AttackChosen Ciphertext AttackAttacker can choose ciphertext and obtain decryption result, reverse-engineer key. RSA is particularly vulnerable without paddingAsymmetric encryption
Side-Channel AttackSide-Channel AttackDeduces key through physical characteristics like execution time, power consumption, electromagnetic radiation, rather than directly attacking algorithm mathematicsAll cryptographic implementations
Replay AttackReplay AttackIntercepts and resends legitimate encrypted messages (e.g., authentication Token), impersonating legitimate userAuthentication protocols
Padding Oracle AttackPadding Oracle AttackExploits server's different responses to padding errors to decrypt ciphertext byte by byte (e.g., POODLE, Lucky 13)CBC mode padding
Downgrade AttackDowngrade AttackForces both parties to use weaker encryption versions or algorithms (e.g., POODLE forces downgrade back to SSL 3.0)Protocol negotiation

Defense Key Points

  • Birthday Attack: Use hash functions of 256-bit or more (SHA-256+), collision requires 2^128 attempts.
  • Length Extension Attack: Use HMAC instead of H(key ‖ message); or switch to SHA-3 (Keccak sponge function structure, naturally immune to this attack).
  • Side-Channel Attack: Use constant-time comparison (e.g., CryptographicOperations.FixedTimeEquals), avoid Timing Attack.
  • Downgrade Attack: Disable all known insecure protocol versions and cipher suites.
Birthday Attack: Why is it called "Birthday"?

Birthday Paradox: In a room, you only need 23 people to have a >50% probability that two people share the same birthday. Intuitively this number is very low (there are 365 days in a year), but the counter-intuitive key is: we are looking for any pair that matches, not "someone sharing a birthday with a specific person."

There are 23 × 22 ÷ 2 = 253 pairs to compare among 23 people, so the probability rises rapidly.

Attack TargetCostAnalogy
Pre-image Attack: Find input corresponding to specific hash value2^n attemptsFind someone who shares a birthday with a specific person
Collision Attack: Find any two inputs with same hash value2^(n/2) attemptsFind any two people in the room who share a birthday

The cost of collision attack is only "half the exponent" of pre-image attack, so collision attack must be considered when choosing hash length.

  • SHA-1 (160-bit): Collision theory requires 2^80 attempts, Google found a collision in 2017 (SHAttered project), SHA-1 officially declared insecure.
  • SHA-256 (256-bit): Collision requires 2^128 attempts, currently uncrackable.
Padding Oracle Attack: How to decrypt ciphertext byte by byte?

CBC decryption formula: P_i = D(C_i) ⊕ C_{i-1}, where D is block decryption, C is ciphertext, P is plaintext.

PKCS#7 Padding Rules: Plaintext end must be padded to 16 bytes. If missing k bytes, pad k bytes with value k:

Missing 1 byte  → pad 01
Missing 2 bytes → pad 02 02
Missing 3 bytes → pad 03 03 03

Attack Principle: Server returns "padding error" if format is invalid after decryption. This error response is an "Oracle" (queryable black box), attacker restores plaintext byte by byte through it:

  1. Take the last ciphertext block C_n and the previous one C_{n-1}.
  2. Try modifying the last byte of C_{n-1} one by one (256 possibilities).
  3. When server returns "padding correct," it means the last byte after decryption is exactly 0x01.
  4. Deduce: D(C_n)[last] = 0x01 ⊕ test value, then reverse-deduce real plaintext: P_n[last] = D(C_n)[last] ⊕ original C_{n-1}[last].
  5. After knowing the last byte, adjust expected padding to 02 02, repeat deduction for the second-to-last byte, until the entire block is restored.

Each byte takes at most 256 queries, 16 bytes per block takes at most 4,096 queries to decrypt an entire block. POODLE and Lucky 13 attacks belong to this category.

For a complete explanation of side-channel attacks (including timing attack byte-by-byte case, law of large numbers, Spectre and cloud co-residency), see Common Software Vulnerability Exploitation Techniques Comparison Table.

Downgrade Attack: How to forge "insufficient capability" to trick server into using old protocol?

The first step of TLS handshake, client sends ClientHello, declaring supported protocol versions and cipher suite list, server selects the highest version from them to respond.

Attack Process (using POODLE as an example):

  1. Attacker (MITM) intercepts client's ClientHello.
  2. Tamper the supported version list from TLS 1.3, 1.2, 1.1, 1.0, SSL 3.0 to only SSL 3.0.
  3. Server receives it and thinks the other side only supports SSL 3.0, downgrades negotiation according to specification.
  4. SSL 3.0's CBC padding rules have POODLE vulnerability, attacker can then decrypt traffic.

Why is attack feasible: To be compatible with old clients (old browsers, old devices), servers usually enable multiple versions simultaneously; as long as the old version is open, the downgrade target exists.

Defense:

  • Server-side: Explicitly disable all versions below TLS 1.1, leaving old versions nowhere to downgrade to.
  • TLS 1.3: Embeds a Downgrade Sentinel in the Finished message hash; if the server detects that ClientHello was tampered with, it terminates the handshake.

Common Cryptographic Tool Command Examples

OpenSSL Common Commands
bash
# --- Generate RSA private key (2048-bit) ---
openssl genpkey -algorithm RSA -out private.pem -pkeyopt rsa_keygen_bits:2048

# --- Export public key from private key ---
openssl pkey -in private.pem -pubout -out public.pem

# --- Generate ECDSA private key (P-256 curve) ---
openssl genpkey -algorithm EC -out ec-private.pem -pkeyopt ec_paramgen_curve:P-256

# --- Generate self-signed certificate (valid for 365 days) ---
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes \
  -subj "/C=TW/ST=Taipei/L=Taipei/O=MyOrg/CN=localhost"

# --- View certificate content ---
openssl x509 -in cert.pem -text -noout

# --- View remote server certificate chain ---
openssl s_client -connect www.google.com:443 -showcerts </dev/null 2>/dev/null | \
  openssl x509 -text -noout

# --- Verify certificate ---
openssl verify -CAfile ca-bundle.pem cert.pem

# --- AES-256-CBC encrypt file (using PBKDF2 to derive key) ---
openssl enc -aes-256-cbc -salt -pbkdf2 -in plain.txt -out encrypted.bin

# --- AES-256-CBC decrypt file ---
openssl enc -aes-256-cbc -d -pbkdf2 -in encrypted.bin -out decrypted.txt

# --- Calculate SHA-256 hash ---
openssl dgst -sha256 file.txt

# --- HMAC-SHA256 ---
openssl dgst -sha256 -hmac "my-secret-key" file.txt
GPG Common Commands
bash
# --- Generate key pair ---
gpg --full-generate-key

# --- List keys ---
gpg --list-keys
gpg --list-secret-keys

# --- Symmetric encrypt file (AES-256, password protected) ---
gpg --symmetric --cipher-algo AES256 -o encrypted.gpg plain.txt

# --- Symmetric decrypt ---
gpg --decrypt -o decrypted.txt encrypted.gpg

# --- Asymmetric encrypt (using recipient's public key) ---
gpg --encrypt --recipient [email protected] -o encrypted.gpg plain.txt

# --- Asymmetric decrypt ---
gpg --decrypt -o decrypted.txt encrypted.gpg

# --- Digital signature ---
gpg --sign --armor -o signed.asc document.txt

# --- Verify signature ---
gpg --verify signed.asc

# --- Export public key ---
gpg --export --armor [email protected] > public.asc

# --- Import public key ---
gpg --import public.asc

Post-Quantum Cryptography (PQC) and Key Encapsulation Mechanism (KEM)

Post-Quantum Cryptography (PQC) is a cryptographic algorithm designed to counter the threat of quantum computers, aiming to replace traditional asymmetric encryption that relies on "large number factorization hard problems" (RSA) or "discrete logarithm hard problems" (ECC, DH). Shor's Algorithm can crack these hard problems with periodic algebraic structures in polynomial time on quantum computers; PQC switches to mathematical foundations that quantum computers cannot accelerate as the security basis.

NIST PQC Standardization Results (Official standard in 2024):

AlgorithmChinese DescriptionTypeMathematical FoundationStandard
CRYSTALS-Kyber (ML-KEM)Module Lattice Key Encapsulation MechanismKey Encapsulation (KEM)LatticeFIPS 203
CRYSTALS-Dilithium (ML-DSA)Module Lattice Digital Signature AlgorithmDigital SignatureLatticeFIPS 204
SPHINCS+ (SLH-DSA)Stateless Hash Digital Signature AlgorithmDigital SignatureHash FunctionFIPS 205

Why Lattice-based hard problems have post-quantum security

The security of Lattice-based cryptography (Lattice-based Cryptography) is built on high-dimensional geometric hard problems such as Learning With Errors (LWE).

Intuitive understanding of LWE: Given a large number of linear equation systems with tiny random errors (b = A·s + e mod q, where A, b are known, s is the hidden secret vector, e is random error), can you reverse-engineer s?

  • No error (e = 0): Solve linear equations, middle school math can solve.
  • Add random error (e ≠ 0): The problem is exponentially difficult, currently neither classical nor quantum computers have known effective algorithms.

Shor's Algorithm uses Quantum Fourier Transform to accelerate periodic algebraic structures; the random error of LWE destroys this regularity, quantum acceleration fails here.

Key Encapsulation Mechanism (KEM):

KEM is the mechanism used in the post-quantum era to securely transmit symmetric keys, functionally equivalent to a "post-quantum digital envelope":

  1. Receiver generates KEM public key / private key pair.
  2. Sender performs Encapsulate with receiver's public key, generating: a ciphertext and a shared secret.
  3. Receiver performs Decapsulate with private key, restoring the same shared secret.
  4. Both sides communicate with symmetric encryption using the shared secret.

"Harvest Now, Decrypt Later" Attack

Attackers collect and store encrypted transmission data now, and decrypt it after quantum computers mature. Even if quantum computers are not practical today, data with long-term confidentiality needs (e.g., government secrets, medical records) needs to start migrating to PQC algorithms now.

Quantum Threat to Symmetric Encryption: Grover's Algorithm

Grover's Algorithm primarily threatens symmetric encryption systems, it can accelerate brute force at a quadratic level, effectively halving the secure key length:

AlgorithmTraditional Security StrengthEffective Strength after Quantum ComputerConclusion
AES-128128 bits64 bits❌ Insufficient, not recommended for long-term protection
AES-256256 bits128 bits✅ Currently considered sufficient, NIST recommended

Symmetric encryption does not need to be replaced with PQC algorithms, increasing key length to 256 bits is sufficient to cope with Grover's Algorithm.

Quantum Key Distribution (QKD)

Quantum Key Distribution (QKD) uses quantum mechanics principles to securely exchange encryption keys between two parties, any eavesdropping behavior will interfere with the quantum state, allowing the receiver to detect it.

Operating Principle (using BB84 protocol as an example):

  1. Sender randomly transmits photon sequences in four polarization states (↕, ↔, ↗, ↘).
  2. Receiver randomly chooses a basis (+ type or × type) to measure each photon.
  3. Both sides compare the bases they used over a public channel, retaining quantum bits where "bases match" as raw key material.
  4. If an eavesdropper measures photons in transit, according to the Heisenberg Uncertainty Principle, quantum states cannot be copied (No-cloning Theorem), the measurement behavior itself changes the quantum state, causing the receiver to detect an abnormal bit error rate, and both sides discard this key.

QKD vs PQC Positioning Differences:

QKDPQC
Security FoundationQuantum physics laws (Quantum No-cloning Theorem)Mathematical hard problems (Lattice, Hash function)
Deployment RequirementRequires dedicated quantum channel (fiber or satellite), high hardware costSoftware algorithm replacement, can operate on existing network infrastructure
Resistance TargetAny eavesdropping (even quantum computers cannot steal keys without leaving traces)Primarily against quantum computer computational cracking (Shor's Algorithm)
MaturityShort-distance commercial (tens to hundreds of kilometers), long-distance relies on relays or satellitesNIST announced first batch of standards in 2024, practical progress is fast
Main LimitationExpensive equipment, distance limited, infrastructure not easy to expandCorrectness of algorithms still being continuously verified
  • QKD solves "whether the key exchange process is eavesdropped"; PQC solves "whether encryption can still resist cracking after computing power increases." The two goals are complementary, not mutually exclusive.
  • "Harvest Now, Decrypt Later" attacks can be prevented by QKD (eavesdropping can be detected at the time), but QKD's high deployment threshold makes PQC a more realistic short-term transition solution.

Homomorphic Encryption

Homomorphic encryption allows performing mathematical operations directly on ciphertext, the result after decryption is equivalent to the result of performing operations on plaintext first and then encrypting, without ever decrypting the original data.

Intuitively, ciphertext looks like a string of meaningless garbled code (e.g., Base64 or Hex), it's hard to imagine being able to "do math" on it. The key is that the design goals of the two types of encryption are different:

Traditional Encryption (AES / RSA)Homomorphic Encryption
Design GoalDeliberately destroy algebraic structure, making ciphertext and plaintext completely unrelatedDeliberately preserve specific algebraic structure, making operations on ciphertext correspond to operations on plaintext
Ciphertext OperationPerform addition/subtraction/multiplication/division on ciphertext, get meaningless results after decryptionPerform addition or multiplication on ciphertext, get correct plaintext operation results after decryption
CostHigh performance, widely appliedWhile preserving algebraic structure and maintaining semantic security, design is complex, performance is extremely low

Modern FHE schemes (BFV, BGV, CKKS, etc.) are built on Ring-LWE Lattice hard problems, ciphertext is essentially high-dimensional vectors/polynomials, and their algebraic structure naturally supports the transmission of addition and multiplication. This also makes FHE simultaneously possess post-quantum security.

TypeEnglishSupported OperationsDescription
Partial Homomorphic (PHE)Partial Homomorphic EncryptionAddition only OR Multiplication onlyImplementation is simpler, RSA multiplication homomorphic belongs to this category
Somewhat Homomorphic (SHE)Somewhat Homomorphic EncryptionAddition + Limited multiplicationError accumulation leads to decryption failure after exceeding limit
Fully Homomorphic (FHE)Fully Homomorphic EncryptionAddition + Multiplication (unlimited times)Theoretically can perform arbitrary calculations, but computational overhead is extremely high
  • Typical Application: Cloud machine learning (cloud providers train or infer models without touching original personal data), cross-institutional medical data joint analysis (institutions analyze together without sharing original data).
  • Current Status of FHE: Computational overhead is far higher than plaintext calculation (currently about thousands to tens of thousands of times slower), still in the research and limited application stage.
  • Different purpose from PQC: PQC solves "how to make encryption resist quantum computer cracking"; homomorphic encryption solves "how to use encrypted data without decrypting it."

Attack Techniques

Malware and Attack Chain

Malware Comparison Table

TypeIndependent Survival (Need host?)Spread and Trigger MethodMain Purpose and FeaturesTypical Example / Note
VirusNo (needs to attach to normal file)Needs user to click or execute host fileDestroy system, infect other filesMacro virus, CIH
WormYes (independent executable)Actively scans network vulnerabilities, self-replicates and spreadsConsumes network bandwidth and system resourcesBlaster, SQL Slammer
TrojanYes (disguised as normal software)Deceives user into actively downloading and installingSteal secrets, open backdoors for remote controlBanking Trojan, RAT (Remote Access Trojan)
RansomwareYesVia phishing emails, vulnerabilities, or Trojan implantationEncrypts files, locks them, extorts decryption ransomWannaCry (has worm spreading characteristics), LockBit
SpywareYesBundled with free software or malicious web pagesKeylogging, monitoring browsing behavior, stealing passwordsKeylogger
Logic BombNo (usually implanted in normal program)Triggers only when specific conditions are met (e.g., specific date, specific operation)Internal employee revenge, timed destructionMalicious database deletion script

OFAC Sanction List Verification Obligation Before Paying Ransom

OFAC (Office of Foreign Assets Control, US Department of the Treasury) maintains a sanction list (SDN List), listing countries, organizations, and individuals sanctioned by the US.

For enterprises headquartered or operating within the US (or involving USD transactions):

  • If deciding to pay ransom, must first verify whether the attacker/payee is on the OFAC sanction list.
  • Providing funds to sanctioned hostile nation hacker organizations or terrorists is a serious federal felony, potentially facing huge fines or even criminal prosecution, regardless of whether it was known, and may be held accountable (strict liability).
  • Even if not on the sanction list, it is recommended to voluntarily disclose to OFAC after payment (voluntary disclosure can mitigate liability).

Confirming whether the target is on the list is not the primary purpose: Enterprises do not pay to avoid becoming a source of funds for sanctioned targets, not to ensure the attacker will definitely decrypt, the latter belongs to the scope of negotiation and technical assessment.

Virus Advanced Variant Technology Comparison

  • Polymorphic Virus: Changes its own encryption signature every time it infects, but the decrypted malicious core code remains the same. The goal is to evade traditional antivirus software signature scanning.
  • Metamorphic Virus: Rewrites its own code every time it infects (e.g., replacing instructions, inserting garbage code), appearance and structure are completely different, but the malicious behavior executed is the same, the most difficult type to detect.

Packing & Obfuscation

Antivirus software's static analysis scans files on the hard disk, comparing signatures of known malicious programs. Packing makes the appearance on the hard disk completely different from the real code, thereby bypassing scanning:

Packing Process:

  1. Packer compresses/encrypts original malicious code, merges with an external shell program (Stub) responsible for unpacking into a new executable file
  2. When antivirus scans, it sees compressed garbage + Stub, cannot find malicious signatures → passes
  3. When user executes, Stub runs first, unpacks/decrypts original code and loads it into memory
  4. Malicious code appears and executes only in memory
TechnologyOperation MethodAttacker GoalCommon Tool/Technique
PackingOriginal code compressed/encrypted and wrapped in Stub, unpacked by Stub at execution and loaded into memoryMake static appearance on hard disk different from real code, bypass signature scanningUPX (general compression), Themida (commercial protection), custom Packer
ObfuscationRewriting code structure (e.g., scrambling execution flow, inserting garbage code), execution result remains unchangedIncrease time cost for reverse engineering and manual analysisVariable renaming, Control Flow Flattening, garbage code insertion
CrypterAdvanced form of packing, protects Payload with high-strength encryption, dynamically decrypts at executionAchieve FUD (Fully Undetectable), file signature changes every time generatedCustom Crypter

How to see through packing: Packed executables present three abnormalities on the hard disk: content looks almost like garbage (loses regularity after compression/encryption), normal program error messages and API names and other readable text disappear, Windows function call list is extremely simplified (Stub only needs a few APIs to load the real program, other calls appear after unpacking).

Countermeasures: Sandbox dynamic analysis (let it run and observe behavior), Memory Dump (analyze after unpacking), behavioral detection instead of signature comparison.

Cyber Kill Chain Comparison Table

The Cyber Kill Chain proposed by Lockheed Martin breaks down APT (Advanced Persistent Threat) attacks into 7 stages:

StageEnglishChineseDescriptionTypical Activity
1ReconnaissanceReconnaissanceCollect target informationOSINT (Open-Source Intelligence), social media investigation, scanning public services
2WeaponizationWeaponizationCreate attack toolsCombine vulnerability exploit with Payload into a deliverable weapon (e.g., malicious PDF)
3DeliveryDeliveryDeliver weapon to targetPhishing emails, malicious websites, USB drop
4ExploitationExploitationTrigger vulnerabilityExploit software vulnerabilities, zero-day attacks, user clicks malicious attachment
5InstallationInstallationImplant persistent backdoorInstall RAT (Remote Access Trojan), create scheduled tasks, modify registry keys
6Command & Control (C2)Command & ControlEstablish remote control channelConnect back to C2 server, receive instructions
7Actions on ObjectivesActions on ObjectivesAchieve final goalData theft, data destruction, lateral movement, ransomware

Cyber Kill Chain vs MITRE ATT&CK

Comparison AspectCyber Kill ChainMITRE ATT&CK
StructureLinear 7-stage chainTactics × Techniques matrix
GranularityHigh-level attack processFine-grained techniques and sub-techniques
Applicable ScenarioUnderstanding overall attack process, post-incident backtrackingWriting threat detection rules, red/blue team exercises
MaintenanceProposed by Lockheed Martin, updated less frequentlyMITRE continuously updates, community contributions
  • Kill Chain defense thinking: Interrupting the attack chain at any stage can stop the attack, the earlier the stage, the lower the cost.
  • ATT&CK defense thinking: Build detection rules for each technique, increasing attacker costs and exposure risks.
  • The two are complementary: Use Kill Chain to understand the overall attack picture, use ATT&CK to build fine-grained detection capabilities.
  • Vulnerability exploitation techniques corresponding to each stage of Kill Chain: Exploitation stage common Buffer Overflow, ROP (Return-Oriented Programming); Installation stage common DLL Side-Loading.
Diagram

Parentheses contain MITRE ATT&CK official tactic IDs, which can be queried for all specific techniques under that tactic at attack.mitre.org.

Kill Chain StageCorresponding ATT&CK TacticSupplement
ReconnaissanceReconnaissance (TA0043)One-to-one correspondence, collecting target information.
WeaponizationResource Development (TA0042)Acquire or build attack infrastructure and tools.
DeliveryInitial Access (TA0001)Phishing, vulnerability exploitation, supply chain attacks, etc.
ExploitationExecution (TA0002), Defense Evasion (TA0005)Execute code after triggering vulnerability, and evade detection.
InstallationPersistence (TA0003), Privilege Escalation (TA0004)Implant backdoor and escalate privileges to maintain access.
C2Command and Control (TA0011)Establish remote control channel.
Actions on ObjectivesCollection (TA0009), Exfiltration (TA0010), Impact (TA0040)Collect, exfiltrate data, or cause damage.

MITRE Defense-Side Frameworks:

In addition to ATT&CK (attacker perspective), MITRE has two defense-side frameworks:

FrameworkPositioningDescription
MITRE D3FENDDefender's EncyclopediaOrganizes defense techniques in a knowledge graph, precisely corresponding to ATT&CK attack techniques. Each D3FEND technique indicates which ATT&CK TTPs it can defend against; content covers Harden, Detect, Isolate, Deceive, Evict five categories of defensive actions.
MITRE ENGAGEActive Defense and Adversarial EngagementFocuses on Deception and adversarial engagement, guiding defenders on how to use decoys (Honeypot / Honey Token), misleading information, etc., as active means to expose TTPs, consume attack resources, and collect threat intelligence.

Positioning Distinction of the